📄 timer0isr.c
字号:
#include <pic18.h>
#include "timer0.h"
#include <stdio.h>
void interrupt ISR(void)
{
if((RBIE)&&(RBIF))
{
/*turn timer on and off*/
if(TIMER_ENA) {TMR0ON=!TMR0ON;
TMR1ON=!TMR1ON;}
/*turn prescaler on and off*/
if (PRESCALER_ENA) PSA=!PSA;
/*select timer mode (counter/timer)*/
if (COUNTER_SEL) T0CS=!T0CS;
/*select timer mode (8/16 bits)*/
if (TIMER_SIZE) T08BIT=!T08BIT;
RBIF=0;
UPDATE_REQUIRED=1;
}
if((TMR0IF)&&(TMR0IE))
{
/*shift value in LED1 to the right by 1*/
LED1<<=1;
if (LED1==0)LED1=DIP1;
TMR0IF=0;
}
if((TMR1IF)&&(TMR1IE))
{
/*shift value in LED2 to the right by 1*/
LED2<<=1;
if (LED2==0) LED2=DIP1;
TMR1IF=0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -