- C/C++ code
#include "iom168V.h"#define CLI() asm("cli")#define SEI() asm("sei")#define BIT(X) (1<<(X))#pragma interrupt_handler timer1_ovf_isr:14 void timer1_ovf_isr(void) { TCNT1H=0x85; TCNT1L=0Xed; ~PORTB;}void main(void){ DDRB=0x40; PORTB|=0X40; CLI(); TCCR1B=0X04;//256分频 TCNT1H=0x85; TCNT1L=0Xed; //设置定时器初值 SEI();//开启总中断 TIMSK1=0x01; while(1); }
貌似进不了中断,为什么?还有#pragma interrupt_handler timer1_ovf_isr:14 中的timer1_ovf_isr可以自己任意写么?
------解决方案--------------------
楼主
~PORTB; 这一句是神马意思,可以改变PORTB端口的状态吗?
PORTB = ~PORTB; 是这样吧