ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
adc_interrupt_10bit.c File Reference
#include "fw_hal.h"

Go to the source code of this file.

Functions

 INTERRUPT (ADC_Routine, EXTI_VectADC)
 
void main (void)
 

Variables

uint16_t res
 

Function Documentation

◆ INTERRUPT()

INTERRUPT ( ADC_Routine  ,
EXTI_VectADC   
)

Definition at line 34 of file adc_interrupt_10bit.c.

35{
37 res = ADC_RESL;
38 res |= (ADC_RES & 0x0F) << 8;
39 // Restart ADC for continuous sampling
40 ADC_Start();
41}
uint16_t res
#define ADC_ClearInterrupt()
Definition: fw_adc.h:24
#define ADC_Start()
Definition: fw_adc.h:22

◆ main()

void main ( void  )

Definition at line 43 of file adc_interrupt_10bit.c.

44{
46 // For debug print
48 // Set ADC1(GPIO P1.1) HIP
50 // Channel: ADC1
51 ADC_SetChannel(0x01);
52 // ADC Clock = SYSCLK / 2 / (1+15) = SYSCLK / 32
54 // Right alignment, high 2-bit in ADC_RES, low 8-bit in ADC_RESL
56 // Enable interrupts
59 // Turn on ADC power
61 // Start ADC
62 ADC_Start();
63
64 while(1)
65 {
66 UART1_TxString("Result: ");
67 UART1_TxHex(res >> 8);
68 UART1_TxHex(res & 0xFF);
69 UART1_TxString("\r\n");
70 SYS_Delay(100);
71 }
72}
#define ADC_SetChannel(__CHANNEL__)
Definition: fw_adc.h:52
#define ADC_SetClockPrescaler(__PRESCALER__)
Definition: fw_adc.h:75
#define ADC_SetResultAlignmentRight()
Definition: fw_adc.h:59
#define ADC_SetPowerState(__STATE__)
Definition: fw_adc.h:21
#define EXTI_ADC_SetIntState(__STATE__)
Definition: fw_exti.h:118
#define EXTI_Global_SetIntState(__STATE__)
Definition: fw_exti.h:115
@ GPIO_Pin_1
Definition: fw_gpio.h:46
#define GPIO_P1_SetMode(__PINS__, __MODE__)
Definition: fw_gpio.h:79
@ GPIO_Mode_Input_HIP
Definition: fw_gpio.h:25
void SYS_SetClock(void)
Definition: fw_sys.c:40
void SYS_Delay(uint16_t t)
Definition: fw_sys.c:65
@ HAL_State_ON
Definition: fw_types.h:71
void UART1_TxString(uint8_t *str)
Definition: fw_uart.c:85
@ UART1_BaudSource_Timer2
Definition: fw_uart.h:34
void UART1_TxHex(uint8_t hex)
Definition: fw_uart.c:79
void UART1_Config8bitUart(UART1_BaudSource_t baudSource, HAL_State_t _1TMode, uint32_t baudrate)
Definition: fw_uart.c:56

Variable Documentation

◆ res

uint16_t res

STC8H3K64S2 AGrnd -> GND AVcc -> VCC AVref -> VCC Vcc -> VCC Gnd -> GND ADC1 -> Test voltage

STC8H1K08 AVref -> VCC Vcc -> VCC Gnd -> GND ADC1 -> Test voltage

Definition at line 32 of file adc_interrupt_10bit.c.