Untitled

 avatar
unknown
plain_text
a year ago
1.9 kB
6
Indexable
#include <xc.h>
#include <libpic30.h>

// PIC24FJ128GA010 Configuration Bit Settings
// CONFIG2
#pragma config POSCMOD = XT           // XT Oscillator mode selected
#pragma config OSCIOFNC = ON          // OSC2/CLKO/RC15 as port I/O (RC15)
#pragma config FCKSM = CSDCMD         // Clock Switching and Monitor disabled
#pragma config FNOSC = PRI            // Primary Oscillator (XT, HS, EC)
#pragma config IESO = ON              // Int Ext Switch Over Mode enabled
// CONFIG1
#pragma config WDTPS = PS32768       // Watchdog Timer Postscaler (1:32,768)
#pragma config FWPSA = PR128         // WDT Prescaler (1:128)
#pragma config WINDIS = ON           // Watchdog Timer Window Mode disabled
#pragma config FWDTEN = OFF          // Watchdog Timer disabled
#pragma config ICS = PGx2            // Emulator/debugger uses EMUC2/EMUD2
#pragma config GWRP = OFF           // Writes to program memory allowed
#pragma config GCP = OFF            // Code protection is disabled
#pragma config JTAGEN = OFF        // JTAG port is disabled

#include "buttons.h"
int main(void) {
unsigned char portValue;
// Port A access
AD1PCFG = 0xFFFF;
TRISA = 0x0000;
portValue = 0b00000000;
while(1) {
if (BUTTON_IsPressed ( BUTTON_S3 ) == true) {
portValue = 0b11110000;
} else if ((BUTTON_IsPressed ( BUTTON_S4 ) == true)) {
portValue = 0b00001111;
}
LATA = portValue;
}
return -1;
}
//int main(void) {
//    unsigned int portValue;
//
//    // Port A access
//    AD1PCFG = 0xFFFF; // Set to digital I/O (not analog)
//    TRISA = 0x0000;   // Set all port bits to be output
//
//                while(1) {
//                    for(int i = 0; i<=256; i++){
//                        portValue = i;
//                        LATA = portValue;
//                        __delay32(1500000); 
//                    }
//                }
//
//    return 0;
//}
Editor is loading...
Leave a Comment