Untitled
unknown
plain_text
a month ago
2.9 kB
2
Indexable
Never
/* * File: main.c * Author: kphan4 * * Created on August 30, 2024 */ #include <xc.h> #include "lcd_display_driver.h" #include <sys/attribs.h> #define CHARS 3 char name[CHARS] = "PHA"; //Khoi Phan char second[CHARS] = "BBB"; void __ISR(_CHANGE_NOTICE_VECTOR, IPL3SOFT) ChaewoN (void){ //display_driver_use_second_line(); if(PORTDbits.RD7 == 0){ //S6 first char if(second[0] == 'Z') second[0] = 'A'; else second[0]++; // LATAbits.LATA0 = 1; display_driver_use_second_line(); lcd_display_driver_write(second, CHARS); } if(PORTDbits.RD13 == 0){ //S4 third char. if(second[2] == 'Z') second[2] = 'A'; else second[2]++; // LATAbits.LATA1 = 1; display_driver_use_second_line(); lcd_display_driver_write(second, CHARS); } if(PORTDbits.RD6 == 0){ //S3 reset. int i; for(i = 0; i < CHARS; i++){ second[i] = 'B'; } // LATAbits.LATA2 = 1; display_driver_use_second_line(); lcd_display_driver_write(second, CHARS); } IFS1bits.CNIF = 0; } void __ISR(_EXTERNAL_2_VECTOR, IPL2SOFT) Chaezer0 (void){ if(second[1] == 'Z') second[1] = 'A'; else second[1]++; display_driver_use_second_line(); lcd_display_driver_write(second, CHARS); IFS0bits.INT2IF = 0; } void main(void){ // Enable JTAG. DDPCONbits.JTAGEN = 0; // Setting tri-state registers for output. TRISBbits.TRISB15 = 0; TRISD = 0xCF; TRISE = 0xFF00; // Interrupt settings. INTCONbits.MVEC = 1; // Enable multi-vector mode. __builtin_disable_interrupts(); // Disable interrupts. CNCONbits.ON = 1; // Turns on CN interrupt. // Sets up switches S3, S4, S6. CNENbits.CNEN15 = 1; CNENbits.CNEN16 = 1; CNENbits.CNEN19 = 1; IPC6bits.CNIP = 3; IPC6bits.CNIS = 1; IFS1bits.CNIF = 0; IEC1bits.CNIE = 1; INTCONbits.INT2EP = 0; // INT2 (S5) triggers on falling edge. IPC2bits.INT2IP = 2; // Priority = 3. IPC2bits.INT2IS = 1; // Sub-prio = 1. IFS0bits.INT2IF = 0; // Clear interrupt flag. IEC0bits.INT2IE = 1; // Enable INT2. __builtin_enable_interrupts(); // Enable interrupts. lcd_display_driver_initialize(); display_driver_use_first_line(); lcd_display_driver_write(name, CHARS); display_driver_use_second_line(); lcd_display_driver_write(second, CHARS); //For debugging // LATAbits.LATA0 = 0; // LATAbits.LATA1 = 0; // LATAbits.LATA2 = 0; // LATAbits.LATA3 = 0; // TRISAbits.TRISA0 = 0; // TRISAbits.TRISA1 = 0; // TRISAbits.TRISA2 = 0; // TRISAbits.TRISA3 = 0; while(1){;} return; }
Leave a Comment