test.c

来自「较新的adc+lcd1602代码」· C语言 代码 · 共 47 行

C
47
字号
//ICC-AVR application builder : 2008-11-4 12:53:50
// Target : M16
// Crystal: 8.0000Mhz

#include <iom16v.h>
#include <macros.h>

#include "delay.h"
#include "lcd1602.h"
#include "adc.h"
//call this routine to initialize all peripherals
void init_devices(void)
{
 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 LCD_init();
 PORTD|=BIT(PD7);
 DDRD|=BIT(PD7);
 
 MCUCR = 0x00;
 GICR  = 0x00;
 TIMSK = 0x00; //timer interrupt sources
 SEI(); //re-enable interrupts
 //all peripherals are now initialized
}

//
void main(void)
{
 unsigned int adc0,adc1;
 init_devices();
 //insert your functional code here...
 LCD_write_string(0,0,"10_Bit ADC Test!");
 delay_nms(2000);
 LCD_write_string(0,0," ADC0:      V   ");
 LCD_write_string(0,1," ADC1:      V   ");
 while(1)
 {
  adc0=GetAdcValue(0);
  LCD_write_adc(7,0,adc0);
  
  adc1=GetAdcValue(1);
  LCD_write_adc(7,1,adc1);
 }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?