main.c
来自「基于AVR单片机的ADC0808模数转换程序.」· C语言 代码 · 共 45 行
C
45 行
//ICC-AVR application builder : 2007-8-31 下午 06:40:58
// Target : M8
// Crystal: 4.0000Mhz
#include <iom8v.h>
#include <macros.h>
#include "0809.h"
#include "SPIshow.h"
void port_init(void)
{
PORTB = 0x00;
DDRB = 0xff;
PORTC = 0x00; //m103 output only
DDRC = 0x00;
PORTD = 0xff;
DDRD = 0x00;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
spi_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void main(void)
{
unsigned long su;
init_devices();
while(1)
{
su=ADC0909(0);
process(su,data);
display(data);
delayms(100);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?