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

nrf_gpio_set and clear function are not working with softdevice enabled

Hey Everyone

I have written a code for using lora rn2483 with nrf52840 using the uart protocol which is configured on 7 and 5 pin. The program was working fine untill i enabled softdevice and included all the files in it.

The gpio set and clear function seems not to be working with softdevice enabled.

I need to use these functions in order to enable the rn2483 module.

I also tried these functions with the ble_app_uart example but they are not working .

Do i need to change some settings or something else?

Kindly help ,its URGENT!

Rajat!

Parents Reply Children
  • Hi

    Thanks for quick action!
    I am provding the piece of code. 

    If i put a breakpoint on the line read_until function.

    The debugger never stops at that point , however if i put a breakpoint on bsp_board_led_on function ,the debugger pauses at that point.

    If i put a breakpoint on nrf_gpio_pin_set function, The breakpoint red dot shows a question mark on it.

    What does it mean and what can be the issue.

    I am using UART on pin 5 as TX and pin 7 as RX. with HWFC DISABLED.

    PIN RST IS P0.04

    int main(void)
    {
    bsp_board_init(BSP_INIT_LEDS);                    /*INITIALIZE ON BOARD LEDS*/
    uart_init_terra(rx_pin,tx_pin);                   /*UART MODULE  INITIALIZED WITH 57600 and pin7 and pin5 as rx and tx*/
    nrf_delay_ms(200);                                
    nrf_gpio_cfg_output(PIN_RST);                     /*RST(P0.04) AS OUTPUT*/
    //uart_write_data("",1);                            /**/
    app_uart_flush();
    nrf_delay_ms(200);
    bsp_board_led_on(BSP_BOARD_LED_0);                /*TURN ON THE LED*/
    
    nrf_gpio_pin_clear(PIN_RST);                      /*RST PIN LOW*/
    nrf_delay_ms(500);
    nrf_gpio_pin_set(PIN_RST);                        /*RST PIN HIGH*/
    nrf_delay_ms(500);
    
    #ifdef DEBUG_CODE
    read_until(0x0A);
    printf("Data : %s", vikram);
    clear_buffer();
    #endif
    }
    
    void read_until(char end)
    {
    
    volatile int cnt=0;
    
    while((vikram[cnt++]=uart_read_data())!=end );                  /*READING AND APPENDING DATA 
                                                                    UNTILL END IS REACHED*/
    vikram[cnt]=0;
    }
    
    void clear_buffer()
    {
    volatile int m=0;
    while(m!=25)
    {
    vikram[m++]=0;
    
    }
    
    
    char  uart_read_data(void)
    {
    char  rx_data;
    
    while (app_uart_get(&rx_data) != NRF_SUCCESS);
    return rx_data;
    }
    
    

  • Have you defined the symbol DEBUG_CODE, in order for read_until to be compiled into the application? The red dot with questionmark means that this line is not included in the application. It have most likely been optimized away by the compiler, as the state is known at compile time. Try turning off optimiaztion in your project settings.

  • Yes i have defined the symbol DEBUG_CODE. I will try the optimization part and let you know how it goes

  • I have set the optimization level to NONE.

    Does this problem have anything to with app_uart_put/get functions?

    When i tried writing app_uart_put('A') to UART pins(in a while(1) loop). I can see that only once ,instead of multiple times. I am using a logic analyzer to view the UART output.

  • Are you checking the error code returned from app_uart_put/get?

    Do you use nrf_gpio_pin_set/clear functions on the same pins you run UART peripheral on?

Related