UARTE crash when init and uninit continoulsy

Hi, I'm developing an project that using 2 UARTE.
My code flow is
1. when timer handler has expried ( set timer_expired_flag = true) (using app_timer)
2. Enable uarte1 to send data to GPS when process complete disable Uarte1 and repeats with Uarte2 to communicate with module SIM
I handled buffer uarte well, but get stuck when enable and disable uarte continuosly. At line 43.
=> My debug terminal 
<error> app: ERROR 0 [NRF_SUCCESS] at C:\nrf_sdk\components\libraries\libuarte\nrf_libuarte_async.c:644
PC at: 0x0002C069
Her is err_code about  "Unexpected RX free input parameter.";
Here is my 2 uartes config pseudo code

Timer I set 1minute/time. 
It's too hard to reproduce this error, because It rarely occur (sometimes I got this error after 4minutes, sometimes I got this after 2 hours)

May I set larger delay ?

NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 0, 1, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 1000, 3);
NRF_LIBUARTE_ASYNC_DEFINE(libuarte2, 1, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 1000, 3); /**<  using app timer for this uarte */

static void uarte1_init(void) {
  uint32_t err_code;
  nrf_libuarte_async_config_t nrf_libuarte_async_config = {
      .tx_pin = TX_PIN_NUMBER1,
      .rx_pin = RX_PIN_NUMBER1,
      .baudrate = NRF_UARTE_BAUDRATE_115200,
      .parity = NRF_UARTE_PARITY_EXCLUDED,
      .hwfc = NRF_UARTE_HWFC_DISABLED,
      .timeout_us = 100,
      .int_prio = APP_IRQ_PRIORITY_LOW_MID};

  err_code = nrf_libuarte_async_init(&libuarte1, &nrf_libuarte_async_config, uarte_event_handler_1, (void *) &libuarte1);
  APP_ERROR_CHECK(err_code);
  nrf_libuarte_async_enable(&libuarte1);
}

static void uarte2_init(void) {
  uint32_t err_code;
  nrf_libuarte_async_config_t nrf_libuarte_async_config2 = {
      .tx_pin = TX_PIN_NUMBER2,
      .rx_pin = RX_PIN_NUMBER2,
      .baudrate = NRF_UARTE_BAUDRATE_115200,
      .parity = NRF_UARTE_PARITY_EXCLUDED,
      .hwfc = NRF_UARTE_HWFC_DISABLED,
      .timeout_us = 100,
      .int_prio = APP_IRQ_PRIORITY_LOW_MID};

  err_code = nrf_libuarte_async_init(&libuarte2, &nrf_libuarte_async_config2, uarte_event_handler_2, (void *) &libuarte2);
  APP_ERROR_CHECK(err_code);
  nrf_libuarte_async_enable(&libuarte2);
}

int main(){

for(;;){
if (timer_expried_flag == true){

uarte1_init()  
nrf_delay_ms(1000);
send_data_to_GPS(); // nRF communicate with GPS module via uarte1
nrf_libuarte_async_uninit(&libuarte1);
nrf_delay_ms(1000);

uarte2_init()  
nrf_delay_ms(1000);
send_data_to_SIM(); // nRF communicate with SIM module via uarte2
nrf_libuarte_async_uninit(&libuarte2);
nrf_delay_ms(1000);

timer_expried_flag == false;

}
}
 
Thank You !

Parents Reply Children
No Data
Related