void interrupt ISR(void) { USB_CDC_ISR(); UART_ISR(); I2C_ISR(); if (INTCONbits.T0IF && INTCONbits.T0IE) { INTCONbits.T0IF = 0; } if (PIR1bits.TMR1IF && PIE1bits.TMR1IE) { PIR1bits.TMR1IF = 0; TMR1H = 0xC0; } if (PIR2bits.TMR3IF && PIE2bits.TMR3IE) { PIR2bits.TMR3IF = 0; } }
//ISR void interrupt ISR(void)// interrupt 0 // ISR (Interrupt Service Routines) { IOC_ISR(); TMR0_ISR(); TMR1_ISR(); // TMR2_ISR(); INT_ISR(); UART_ISR(); I2C_ISR(); }
void interrupt ISR(void) { UART_ISR(); if(INTCONbits.TMR0IF) { INTCONbits.TMR0IF = 0; static uint8_t prev_A; static uint8_t prev_B; LATB7 = !LATB7; if (A_PULSE != prev_A) { prev_A = A_PULSE; if (A_PULSE) { if (B_PULSE) { encoder--; } else { encoder++; } } else { if (B_PULSE) { //encoder++; } else { //encoder--; } } } if (B_PULSE != prev_B) { prev_B = B_PULSE; if (B_PULSE) { if (A_PULSE) { //encoder++; } else { //encoder--; } } else { if (A_PULSE) { //encoder--; } else { //encoder++; } } } } }
/* ** =================================================================== ** Event : UART_OnRxChar (module Events) ** ** Component : UART [AsynchroSerial] ** Description : ** This event is called after a correct character is received. ** The event is available only when the <Interrupt ** service/event> property is enabled and either the <Receiver> ** property is enabled or the <SCI output mode> property (if ** supported) is set to Single-wire mode. ** Parameters : None ** Returns : Nothing ** =================================================================== */ void UART_OnRxChar(void) { UART_ISR(); }
#include "uart.h" #include <xc.h> #include <stdint.h> #include "platform.h" #define BUFFER_SIZE 32 #define BUFFER_MASK (BUFFER_SIZE - 1) volatile char rxbuffer[BUFFER_SIZE]; volatile char txbuffer[BUFFER_SIZE]; volatile uint8_t txip, txop, rxip, rxop; void interrupt isr(void){ UART_ISR() } void uart_init(unsigned long baud){ unsigned long spbrg_calc = ((_XTAL_FREQ/baud)/16)-1; SPBRG = spbrg_calc; txip = txop = rxip = rxop = 0; TXSTAbits.BRGH = 1; RCSTAbits.CREN = 1; PIE1bits.RCIE = 1; TXSTAbits.TXEN = 1; RCSTAbits.SPEN = 1; PIR1bits.TXIF = 0; PIR1bits.RCIF = 0; }