📄 main.c
字号:
#include "71x_lib.h"
#include "LCD.h"
void Main(void)
{
#ifdef DEBUG
debug();
#endif
LCD_Init();
// Configure the used analog input to HI_AIN_
GPIO_Config(GPIO1, 0x0001, GPIO_HI_AIN_TRI);
// Initialize the conveter register.
ADC12_Init();
// Configure the prescaler register using the configured PCLK
// with a sampling frequency=100Hz
ADC12_PrescalerConfig(100);
// Select the conversion mode=single channel
ADC12_ModeConfig(ADC12_SINGLE);
// Select the channel to be converted
ADC12_ChannelSelect(ADC12_CHANNEL0);
// Start the Converter
ADC12_ConversionStart();
LCD_Goto(0, 0);
LCD_Puts("ADC: ");
while(1)
{
int n, i;
// Wait until the availabiliy of data in the specific flags
while(ADC12_FlagStatus(ADC12_DA0) == RESET);
// Get the conversion result from the correponding Data register
n = ADC12_ConversionValue(ADC12_CHANNEL0);
ADC12->CSR &= ~ADC12_DA0;
// Show the result on LCD
LCD_Goto(0, 5);
LCD_Printf("%4d(0x%03X)", n, n);
LCD_Goto(1, 0);
for(i = 0; i < 16; i++)
LCD_Putc('-');
LCD_Goto(1, n >> 8);
LCD_Putc('+');
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -