This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Erase the preload code for the external board

I have two BC805M EK

Board 1: when I upload the (LED controlled by reset button) code to it, it works fine. 

Board 2: when I upload the LED control code to it, I could see the code has been uploaded correctly by observing the LED (flash twice). However,  whenever I press the reset button, the board restarts the code from beginning again (i.e. LED flashes twice again). 

The code is given below: 

int main(void)
{    
    // Read <nrf_gpio.h> for more details of the following macros
    nrf_gpio_cfg_output(RED_LED_PIN);                             // Configure the pin as the output
    nrf_gpio_cfg_input(BUTTON_PIN,GPIO_PIN_CNF_PULL_Disabled);    // Configure the pin as the input
    
    // Toohle Red LED on and off
    
    nrf_gpio_pin_clear(RED_LED_PIN);    // Set the pin to LOW
    nrf_delay_ms(100);
    nrf_gpio_pin_set(RED_LED_PIN);      // Set the pin to HIGH
    nrf_delay_ms(100);
    nrf_gpio_pin_clear(RED_LED_PIN);
    nrf_delay_ms(100);
    nrf_gpio_pin_set(RED_LED_PIN);
    nrf_delay_ms(100);
    nrf_gpio_pin_clear(RED_LED_PIN);

    for(;;){
        // Read the BC805M EK schematic sheet to understand the logic
        RESET_BUTTON_STATE = nrf_gpio_pin_read(BUTTON_PIN);
        if (RESET_BUTTON_STATE==0)
        {
            nrf_gpio_pin_clear(RED_LED_PIN);  // If the Button pin voltage is LOW (pressed), set LED pin to LOW, hence, turn LED on
        }else{
            nrf_gpio_pin_set(RED_LED_PIN);    // If the Button pin voltage is HIGH (not pressed), set LED pin to LOW, hence, turn LED off
        } 
    }

}

2 boards have the same code, same hardware.

I don't know what I did to board 1 before. I guess it's caused by not easing the preload code on board #2? So I used nRF Connect on Windows PC ---> Programmer ---> Erase all, then re-upload the code, but it doesn't help. 

Do you have any other clue to this situation, please? Thanks! 

Related