492
// UART transmit function void UART_Transmit(char data) { while (!TXIF); // Wait until the transmit buffer is empty TXREG = data; // Transmit the data } // UART send string function void UART_SendString(const char *str) { while (*str) { UART_Transmit(*str++); } } void __interrupt() ISR() { if (TMR2IF) { // Check if Timer2 overflow interrupt flag is set TMR2IF = 0; // Clear the interrupt flag // Increment the interrupt counts interrupt_count1++; interrupt_count2++; interrupt_count3++; interrupt_count4++; interrupt_count5++; // Toggle LEDs based on the specified intervals if (interrupt_count1 >= 100) { // 10 seconds (assuming 100 ms overflow time) PORTBbits.RB0 ^= 1; // Toggle LED on RB0 interrupt_count1 = 0; } if (interrupt_count2 >= 200) { // 20 seconds PORTBbits.RB1 ^= 1; // Toggle LED on RB1 interrupt_count2 = 0; } if (interrupt_count3 >= 300) { // 30 seconds PORTBbits.RB2 ^= 1; // Toggle LED on RB2 interrupt_count3 = 0; } if (interrupt_count4 >= 400) { // 40 seconds PORTBbits.RB3 ^= 1; // Toggle LED on RB3 interrupt_count4 = 0; } } }