I adapted an MPLAB X program from Dogan Ibrahim's book based on PIC18 microcontroller for my PIC32 WiFire ChipKit. However the following two configuration statements generated errors during building (the syntax is unknown to the compiler) and I therefore commented them out.
The program was able to build, however it could not do as programmed (the LED 4 did not switch on when button 1 was pressed). I think this is related to the statements I commented out, Kindly assist to troubleshoot and for the correct syntax. Below is the full program.
Question
Tawachi
Hi,
I adapted an MPLAB X program from Dogan Ibrahim's book based on PIC18 microcontroller for my PIC32 WiFire ChipKit. However the following two configuration statements generated errors during building (the syntax is unknown to the compiler) and I therefore commented them out.
//Configuration: Ext reset, Watchdog OFF, HS oscillator
//#pragma config MCLRE = ON, WDT = OFF, OSC = HS
//MEMCONbits.EBDIS = 1; //Enable input / output functions
The program was able to build, however it could not do as programmed (the LED 4 did not switch on when button 1 was pressed). I think this is related to the statements I commented out, Kindly assist to troubleshoot and for the correct syntax. Below is the full program.
#include <stdio.h>
#include <stdlib.h>
#include <xc.h>
//Configuration: Ext reset, Watchdog OFF, HS oscillator
//#pragma config MCLRE = ON, WDT = OFF, OSC = HS
//
//Define switch and LED connections
#define BTN1 PORTAbits.RA5
#define LED4 PORTGbits.RG15
//
//Define clock frequency
#define _XTAL_FREQ 10000000
//
//Start of main program
int main(int argc, char** argv) {
TRISAbits.TRISA5 = 1; //Configure RA05 as input
TRISGbits.TRISG15 = 0; //Configure RG15 as output
//MEMCONbits.EBDIS = 1; //Enable input / output functions
for (;;) { //do forever
if (BTN1 == 0) //If BTN1 is pressed
LED4 =1; // LED 4 is turned ON
else
LED4 =0;
}
}
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.