|
楼主 |
发表于 2009-7-30 19:13:39
|
显示全部楼层
谢谢楼上两位,我刚刚试了,可以闪烁显示某个字符主题程序如下,不过写得比较笨拙,见笑了!!
int time_counter; // 中断次数计数单元
bit time_1s_ok,once,temp;
// Timer 0 比较匹配中断服务
interrupt [TIM0_COMP] void timer0_comp_isr(void)
{
if (++time_counter>=500)
{
time_counter = 0;
time_1s_ok = ~time_1s_ok;
}
}
void main(void)
{
// T/C0 初始化
TCCR0=0x0B; // 内部时钟,64分频(4M/64=62.5KHz),CTC模式
TCNT0=0x00;
OCR0=0x7C; // OCR0 = 0x7C(124),(124+1)/62.5=2ms
TIMSK=0x02; // 允许T/C0比较匹配中断
lcd_init(16); // initialize the LCD for 2 lines & 16 columns
time_1s_ok=1;
once=1;
temp=1;
#asm("sei")
while(1)
{
if(once==1)
{
lcd_clear(); // clere the LCD
lcd_putsf("It's demo_6_8.c"); // display the message
once=0; // display the message only once
}
if(temp!=time_1s_ok) // the message blinks every 1s
{
lcd_gotoxy(5,0);
if(time_1s_ok)lcd_putchar('d');
else lcd_putchar(0x20);
temp=time_1s_ok;
}
}
} |
|