📄 main.c
字号:
//ICC-AVR application builder : 2005-3-27 19:38:48
// Target : M16
// Crystal: 7.3728Mhz
#include <iom16v.h>
#include <macros.h>
#include "Cpld_Read.h"
#include "Display.h"
//#define DEBUG
//Global varible declare
//unsigned char TimeFlag=0;
void port_init(void)
{
PORTA = 0xFF;
DDRA = 0x00;
PORTB = 0xFF;
DDRB = 0x0F;
PORTC = 0xFF; //m103 output only
DDRC = 0x00;
PORTD = 0xFF;
DDRD = 0x00;
}
//TIMER0 initialisation - prescale:1
// WGM: Normal
// desired value: 200Hz
// actual value: Out of range
//void timer0_init(void)
//{
//TCCR0 = 0x00; //stop
//TCNT0 = 0x70 ; //set count
//OCR0 = 0x00 ; //set compare
//TCCR0 = 0x01; //start timer
//}
/*#pragma interrupt_handler timer0_ovf_isr:10
void timer0_ovf_isr(void)
{
TCNT0 = 0x70 ; //reload counter value
TimeFlag=1;
}*/
//UART0 initialisation
// desired baud rate: 115200
// actual: baud rate:115200 (0.0%)
// char size: 8 bit
// parity: Disabled
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
//timer0_init();
Cpld_Init();
Disp_Init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x01; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialised
}
void main()
{
int CpldResult1;
int CpldResult2;
init_devices();
Cpld_Set();
while(1)
{
CpldResult1=Cpld_Read(0);
CpldResult2=Cpld_Read(1);
#ifdef DEBUG
Cpld_Set();
Display(1234,0);
Display(4321,2);
#else
Display(CpldResult1,0);
Display(CpldResult2,2);
#endif
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -