I am trying to develop a program using the nRFGo kit from Nordic Semiconductor. I built a simple example would turn off LEDs when I pressed a button on the board. I wanted to modify this code such that if I pressed a combination of buttons then a binary representation of the button pressed would be displayed with LEDs on the board. My code compile fine and I can get the code to download into the board but it does not appear to function at all like I intended.
Here is an excerpt from my main.c
//#include <Nordic\reg24le1.h> #include "reg24le1_edit.h" //#include "hal_nrf.h" //#include "radio.h" //#include "application.h" #include "system.h" #include "defines.h" void main(void) { mcu_init(); // EA = 1; // Global interrupt enable // boot_mess(); /* LIGHT_0_LED(); delay_10ms(); LIGHT_1_LED(); delay_10ms(); LIGHT_2_LED(); delay_10ms(); LIGHT_3_LED(); delay_10ms(); LIGHT_4_LED(); delay_10ms(); LIGHT_5_LED(); delay_10ms(); LIGHT_6_LED(); delay_10ms(); LIGHT_7_LED(); delay_10ms(); LIGHT_8_LED(); delay_10ms(); LIGHT_9_LED(); delay_10ms(); LIGHT_10_LED(); delay_10ms(); LIGHT_11_LED(); delay_10ms(); LIGHT_12_LED(); delay_10ms(); */ LIGHT_ALL_LED(); /* while(1) { LIGHT_ALL_LED(); } */ // LIGHT_0_LED(); while(1) { if((B0 == OFF) && (B2 == OFF)) { // LED0 = OFF; LIGHT_1_LED(); } if((B0 == OFF) && (B3 == OFF)) { // LED0 = ON; // turn on LED LIGHT_2_LED(); } if((B0 == OFF) && (B7 == OFF)) { // LED0 = ON; // turn on LED LIGHT_3_LED(); } if((B4 == OFF) && (B2 == OFF)) { // LED0 = OFF; LIGHT_4_LED(); } if((B4 == OFF) && (B3 == OFF)) { // LED0 = ON; // turn on LED LIGHT_5_LED(); } if((B4 == OFF) && (B7 == OFF)) { // LED0 = ON; // turn on LED LIGHT_6_LED(); } if((B5 == OFF) && (B2 == OFF)) { // LED0 = OFF; LIGHT_7_LED(); } if((B5 == OFF) && (B3 == OFF)) { // LED0 = ON; // turn on LED LIGHT_8_LED(); } if((B5 == OFF) && (B7 == OFF)) { // LED0 = ON; // turn on LED LIGHT_9_LED(); } if((B6 == OFF) && (B2 == OFF)) { // LED0 = OFF; LIGHT_10_LED(); } if((B6 == OFF) && (B3 == OFF)) { // LED0 = ON; // turn on LED LIGHT_11_LED(); } if((B6 == OFF) && (B7 == OFF)) { // LED0 = ON; // turn on LED LIGHT_12_LED(); } else // Released B0 during "boot": { // Enter PTX mode (Transmitter) // radio_init(TRANSMITTER); // transmitter_mode(); LIGHT_0_LED(); } } } void LIGHT_ALL_LED(void) { P13 = ON; //LSb P12 = ON; P11 = ON; P06 = ON; } void LIGHT_0_LED(void) { P13 = OFF; //LSb P12 = OFF; P11 = OFF; P06 = OFF; } void LIGHT_1_LED(void) { P13 = ON; //LSb P12 = OFF; P11 = OFF; P06 = OFF; } void LIGHT_2_LED(void) { P13 = OFF; //LSb P12 = ON; P11 = OFF; P06 = OFF; } void LIGHT_3_LED(void) { P13 = ON; //LSb P12 = ON; P11 = OFF; P06 = OFF; } void LIGHT_4_LED(void) { P13 = OFF; //LSb P12 = OFF; P11 = ON; P06 = OFF; } void LIGHT_5_LED(void) { P13 = ON; //LSb P12 = OFF; P11 = ON; P06 = OFF; } void LIGHT_6_LED(void) { P13 = OFF; //LSb P12 = ON; P11 = ON; P06 = OFF; } void LIGHT_7_LED(void) { P13 = ON; //LSb P12 = ON; P11 = ON; P06 = OFF; } void LIGHT_8_LED(void) { P13 = OFF; //LSb P12 = OFF; P11 = OFF; P06 = ON; } void LIGHT_9_LED(void) { P13 = ON; //LSb P12 = OFF; P11 = OFF; P06 = ON; } void LIGHT_10_LED(void) { P13 = OFF; //LSb P12 = ON; P11 = OFF; P06 = ON; } void LIGHT_11_LED(void) { P13 = ON; //LSb P12 = ON; P11 = OFF; P06 = ON; } void LIGHT_12_LED(void) { P13 = OFF; //LSb P12 = OFF; P11 = ON; P06 = ON; }
some defines
#define B0 P10 #define B2 P02 #define B3 P03 #define B4 P14 #define B5 P15 #define B6 P16 #define B7 P07 #define LED0 P06 #define LED1 P11 #define LED2 P12 #define LED3 P13 #define ON 1 #define OFF 0
mcu int function
void mcu_init(void) { P0 = 0; // Port setup P0DIR = P0_SETUP; //0xF0; // P0.0 - P0.3 output LEDS // P0.4 - P0.7 inputs BUTTONS P0CON = 0; P1 = 0; // Port setup P1DIR = P1_SETUP; P1CON = 0; RFCKEN = 1; // enable L01 clock RF = 1; // enable RF interrupt }
I am trying to turn on one LED on PORT0 and 3 on PORT1, but only one of the LEDs will only light up when I download the code to the board. If I turn off power and turn it back on, none of the LEDs will come on.
Does anyone have any suggestions? Thanks for the help.