timer2isr.c
来自「picc_18v 8.35pl35 PIC18系列单片机开发C编译器」· C语言 代码 · 共 42 行
C
42 行
#include <pic18.h>
#include "timer2.h"
#include <stdio.h>
void interrupt ISR(void)
{
if((RBIE)&&(RBIF))
{
TMR2IE=0; /*Disable the TIMER0 interrupt */
if(TIMER_ENA) /*Turn timers on and off*/
{
TMR0ON=!TMR0ON;
TMR2ON=!TMR2ON;
}
if(TIMER_UPDATE)
{
T2CON=T2CON&0b00000100;
T2CON=T2CON|(PORTE&0b11111011); /*Update prescalar and postscalar settings for TIMER2*/
PR2=PORTD; /*Update value of period register for TIMER2*/
}
RBIF=0;
UPDATE_REQUIRED=1;
}
if((TMR0IF)&&(TMR0IE))
{
/*shift value in LED2 to the right by 1*/
LED2<<=1;
if (LED2==0) LED2=1;
TMR0IF=0;
}
if((TMR2IF)&&(TMR2IE))
{
/*shift value in LED1 to the right by 1*/
LED1<<=1;
if (LED1==0) LED1=1;
TMR2IF=0;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?