timer0isr.c
来自「picc_18v 8.35pl35 PIC18系列单片机开发C编译器」· C语言 代码 · 共 41 行
C
41 行
#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 + =
减小字号Ctrl + -
显示快捷键?