📄 main.c
字号:
//ICC-AVR application builder : 2008-4-27 16:46:06
// Target : m48
// Crystal: 8.0000Mhz
#include <iom48v.h>
#include <macros.h>
void port_init(void)
{
PORTB = 0x00;
DDRB = 0x02;
PORTC = 0x00; //m103 output only
DDRC = 0x01;
PORTD = 0x00;
DDRD = 0x00;
}
void timer1_init(void)
{
TCCR1B = 0x00; //stop
TCNT1H = 0xFC; //setup
TCNT1L = 0xA3;
OCR1AH = 0x03;
OCR1AL = 0x5D;
OCR1BH = 0x03;
OCR1BL = 0x5D;
ICR1H = 0x03;
ICR1L = 0x5D;
TCCR1A = 0x40;
TCCR1B = 0x0B; //start Timer
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
timer1_init();
MCUCR = 0x00;
EICRA = 0x00; //extended ext ints
EIMSK = 0x00;
TIMSK0 = 0x00; //timer 0 interrupt sources
TIMSK1 = 0x00; //timer 1 interrupt sources
TIMSK2 = 0x00; //timer 2 interrupt sources
PCMSK0 = 0x00; //pin change mask 0
PCMSK1 = 0x00; //pin change mask 1
PCMSK2 = 0x00; //pin change mask 2
PCICR = 0x00; //pin change enable
PRR = 0x00; //power controller
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void main(void)
{
// static unsigned char cChg = 1;
init_devices();
while(1)
{
if( (PINB & (0x01<<0)) == 0x00 )
{
TCCR1A = 0x00;
}
else
{
TCCR1A = 0x40;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -