EasyManuals Logo

STMicroelectronics STM8 User Manual

STMicroelectronics STM8
126 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #59 background imageLoading...
Page #59 background image
void ADC1_setup(void)
{
ADC1_DeInit();
ADC1_Init(ADC1_CONVERSIONMODE_SINGLE,
ADC1_CHANNEL_1,
ADC1_PRESSEL_FCPU_D10,
ADC1_EXTTRIG_GPIO,
DISABLE,
ADC1_ALIGN_RIGHT,
ADC1_SCHMITTTRIG_CHANNEL1,
DISABLE);
ADC1_AWDChannelConfig(ADC1_CHANNEL_1, ENABLE);
ADC1_SetHighThreshold(600);
ADC1_SetLowThreshold(200);
ADC1_Cmd(ENABLE);
}
void lcd_print(unsigned char x_pos, unsigned char y_pos, unsigned int value)
{
char chr = 0x00;
chr = ((value / 1000) + 0x30);
LCD_goto(x_pos, y_pos);
LCD_putchar(chr);
chr = (((value / 100) % 10) + 0x30);
LCD_goto((x_pos + 1), y_pos);
LCD_putchar(chr);
chr = (((value / 10) % 10) + 0x30);
LCD_goto((x_pos + 2), y_pos);
LCD_putchar(chr);
chr = ((value % 10) + 0x30);
LCD_goto((x_pos + 3), y_pos);
LCD_putchar(chr);
}
Explanation
The code for the AWD example is just as the one demonstrated in the ADC example. However, this
time the ADC channel is channel 1 (PB1). Setting up the AWD is simple. We just need to set the limits,
specify which channel to be monitored and enable the AWD unit.
ADC1_AWDChannelConfig(ADC1_CHANNEL_1, ENABLE);
ADC1_SetHighThreshold(600);
ADC1_SetLowThreshold(200);
Here we have set 600 and 200 ADC counts as upper and lower limits respectively.

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the STMicroelectronics STM8 and is the answer not in the manual?

STMicroelectronics STM8 Specifications

General IconGeneral
BrandSTMicroelectronics
ModelSTM8
CategoryMicrocontrollers
LanguageEnglish

Related product manuals