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

Wakeup the nrf51422 with UART pins.

Hello All,

Currently i am working on nrf51422 DK board(PCA10028). I am using SDK 12.3.0 ,from this i have referred the ble_app_uart  example for implementing the UART and it is working fine.

As per our application i want to the wakeup the BLE from system off using RX or TX pin. I referred the example for waking up the BLE using the GPIO pins and test it ,the ble will wakeup by driving the pin low. 
So for configuring the wakeup for BLE i approach with below steps.

1. Configuring the rx or tx as gpio input  and configuring the gpio as wakeup pin with sense low during the startup of ble.

2 Read the  GPIO status, if it is low than  deint the gpio using nrf_gpio_cfg_default API than  init that pin as uart tx or else go to system off mode if the status is high.

The problem is occurring that when it wakes up from the system off mode and when it try to configure the wakeup pin as uart the system reset occur.

But if i change the pins it works fine. Can anyone help me out for what approach should i use to wake up the BLE using UART ? I have code snippet as below.

/********************************************************************************************************************/

int main(void)
{

    uint32_t err_code;

    // Initialize.
   APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
  ble_stack_init();

  nrf_gpio_cfg_input(13,NRF_GPIO_PIN_PULLUP);
  nrf_gpio_cfg_sense_input(13, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);


  if(nrf_gpio_pin_read(13))
 {

   sd_power_system_off();

  }
else
{

  nrf_gpio_cfg_default(13);
  uart_init();

}
gap_params_init();
services_init();
advertising_init();
conn_params_init();

sd_ble_gap_adv_data_set((const uint8_t*)data,sizeof(data),NULL,NULL);


err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
// Enter main loop.

  for (;;)
  {
     power_manage();
  }
}

/*******************************************************************************************************************/

Any help will be greatly appreciated.

Regards,

Amit 

Parents
  • Hello Amit,

    The problem is occurring that when it wakes up from the system off mode and when it try to configure the wakeup pin as uart the system reset occur.

    Is that the  APP_UART_COMMUNICATION_ERROR event inside your uart event handler that resets the controller? If so, can you try to just print out the p_event->data.error_communication in the log (or debug to see what it is), instead of passing it into the APP_ERROR_CHECK(p_event->data.error_communication)? 

    Printing it just to see what reason it is. What I really want to know is whether it behaves properly if you just remove the APP_ERROR_HANDLER(p_event->data.error_communication); inside the APP_UART_COMMUNICATION_ERROR event in your uart event handler.

    Best regards,

    Edvin

  • Dear Edvin,

    Thanks for your Kind Response!!!

    Yes ,the APP_UART_COMMUNICATION_ERROR  event inside the uart event handler causing the reset of the controller.

    The value i got from  p_event->data.error_communication is 12 ,i don't know what it means. I also comment the APP_ERROR_CHECK(p_event->data.error_communication) ,still it reset the controller Kindly give your feedback for the same.

    Regards,

    Amit 

  • Hello,

    Looking at the struct app_uart_evt_t in app_uart.h on line 118, it says that the APP_UART_COMMUNICATION_ERROR event contains the value of the ERRORSRC from the UART peripheral, which you can see in Table 279 in the reference manual.

    So, 12 = 0xb1100, meaning D=1, C=1, B=0, A=0 (in the table).

    D means that it is a break, which is what you are seeing. C means "Framing error", which is caused by that the data doesn't seem to fit with the baudrate of the UART. This is probably because it takes some time to start up the UART, and the nRF thinks that the first bit is too short. 

     

    Amitkumar said:
    still it reset the controller Kindly give your feedback for the same.

     Can you try to:

    1: disable optimization in your project, and

    2: define DEBUG in your preprocessor defines.

    Then set a breakpoint on line 76 in app_error.c. Does it stop at this breakpoint? If so it should point to a place in your project. What is .line_num, p_file_name, and .err_code? and what is the function that returned the err_code that was passed into APP_ERROR_CHECK() on this place in your project?

Reply
  • Hello,

    Looking at the struct app_uart_evt_t in app_uart.h on line 118, it says that the APP_UART_COMMUNICATION_ERROR event contains the value of the ERRORSRC from the UART peripheral, which you can see in Table 279 in the reference manual.

    So, 12 = 0xb1100, meaning D=1, C=1, B=0, A=0 (in the table).

    D means that it is a break, which is what you are seeing. C means "Framing error", which is caused by that the data doesn't seem to fit with the baudrate of the UART. This is probably because it takes some time to start up the UART, and the nRF thinks that the first bit is too short. 

     

    Amitkumar said:
    still it reset the controller Kindly give your feedback for the same.

     Can you try to:

    1: disable optimization in your project, and

    2: define DEBUG in your preprocessor defines.

    Then set a breakpoint on line 76 in app_error.c. Does it stop at this breakpoint? If so it should point to a place in your project. What is .line_num, p_file_name, and .err_code? and what is the function that returned the err_code that was passed into APP_ERROR_CHECK() on this place in your project?

Children
Related