Untitled
unknown
plain_text
7 months ago
1.4 kB
5
Indexable
Never
#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" void program1() { } 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; }
Leave a Comment