?? ff.c
字號:
//ICC-AVR application builder : 2009-5-19 13:21:53
// Target : M16
// Crystal: 4.0000Mhz
#include <iom16v.h>
#include <macros.h>
flash unsigned char led_7[16]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,0xC6,0xA1,0x80,0x8E};
unsigned char counter;
void port_init(void)
{
PORTA = 0xFF;
DDRA = 0xFF;
PORTB = 0xFF;
DDRB = 0x00;
PORTC = 0xFF; //m103 output only
DDRC = 0x00;
PORTD = 0xFF;
DDRD = 0x00;
}
#pragma interrupt_handler int0_isr:2
void int0_isr(void)
{
//external interupt on INT0
if (++counter>=16) counter = 0;
}
#pragma interrupt_handler int1_isr:3
void int1_isr(void)
{
//external interupt on INT1
if (counter) --counter;
else counter = 15;
}
//call this routine to initialise all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
MCUCR = 0x0A;
GICR = 0xC0;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialised
}
void main(void)
{
PORTA=0xFF;
DDRA=0xFF;
GICR|=0xC0; // 允許INT0、INT1中斷
MCUCR=0x0A; // INT0、INT1下降沿觸發
GIFR=0xC0; // 清除INT0、INT1中斷標志位
counter = 0; // 計數單元初始化為0
//#asm("sei") // 全局中斷允許
while (1)
{
PORTA = led_7[counter]; // 顯示計數單元
int0_isr();
int1_isr();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -