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

libuarte init with ANT softdevice ?

Dear Members,

I want to use libuarte with ANT and softdevice,

When I initialize libuarte,

The app keeps restarting by itself.

/**********init from libuarte*****/
			 //err_code=nrf_drv_clock_init();
			 //APP_ERROR_CHECK(err_code);
			// NRF_LOG_INFO("Err_code nrf_drv_clk %u",err_code);
			 
			  //nrf_drv_clock_lfclk_request(NULL);
				
				nrf_libuarte_async_config_t nrf_libuarte_async_config1 = {
            .tx_pin     = SER_APP_TX_PIN,
            .rx_pin     = SER_APP_RX_PIN,
            .baudrate   = NRF_UARTE_BAUDRATE_9600,
            .parity     = NRF_UARTE_PARITY_EXCLUDED,
            .hwfc       = NRF_UARTE_HWFC_DISABLED,
            .timeout_us = 1000,
            .int_prio   = APP_IRQ_PRIORITY_LOW
			      
    };
		err_code=nrf_libuarte_async_init(&libuarte1, &nrf_libuarte_async_config1, uart_event_handler1, (void *)&libuarte1);
			APP_ERROR_CHECK(err_code);
		NRF_LOG_INFO("Err_code libuarte_init libuarte1 %u",err_code);
  	nrf_libuarte_async_enable(&libuarte1);

    GPS_Init();		
		/**********init from libuarte*****/

I commented out

 //err_code=nrf_drv_clock_init();

 //nrf_drv_clock_lfclk_request(NULL);

//nrf_libuarte_async_enable(&libuarte1);

to stabilize the application,

libuarte setting :

NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 1, 2, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3); //timer0 id =2, rtc1 id =2

what do I miss here ? is it related with my app timer conflicting with libuarte timer ?

I get this in my log  :  

<error> hardfault: HARD FAULT at 0x00017FB8

<error> hardfault:   R0:  0x20001064  R1:  0x39000000  R2:  0x00000010  R3:  0x0000000F

<error> hardfault:   R12: 0x20000E08  LR:  0x0001E39F  PSR: 0x21000029

<error> hardfault: Cause: Data bus error (PC value stacked for the exception return points to the instruction that caused the fault).

<error> hardfault: Bus Fault Address: 0x39000000

Is
NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

conflicting with my current UART setting for NRF_LOG in softdevice ? it's using the same port UART0

Thanks

Parents
  • Hi,

    It is not clear to me how your application looks, so it is difficult to suggest much.

    I noticed this though:

    I commented out

     //err_code=nrf_drv_clock_init();

     //nrf_drv_clock_lfclk_request(NULL);

    //nrf_libuarte_async_enable(&libuarte1);

    to stabilize the application,

    The first two is not directly related to the libuarte, and if you use a SoftDevice the LFCKL is allready started, so it does not matter if you use it or not. However, you need to call nrf_libuarte_async_enable() before using it. To be honest it is not so reassuring if you comment out blindly in order to attempt to stabilize the application. May I suggest you refer to the libuarte example in the SDK? That shows you how to use it.

    Once you understand the example you can copy it to your application and make necessary adjustments, where we come to this:

    Is
    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

    conflicting with my current UART setting for NRF_LOG in softdevice ? it's using the same port UART0

    Yes, you cannot use the same peripheral for two things (at the same time). The libuarte is quite resource intensive, and needs a UARTE instance two timers and and RTC, as you can see from the API doc of NRF_LIBUARTE_ASYNC_DEFINE. You need to ensure that there are no overlaps. When doing so, keep in mind that the SoftDevice use TIMER0 and RTC0. So that cannot be used. The app_timer use RTC1, which you typically want to use, so that should also be avoided.

  • I'm using libuarte for UART1 only now,

    NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 1, 2, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3); //timer0 id =2, rtc1 id =2

    and the app gives me  :


    rror> app: Fatal error
                                                           

    arning> app: System reset
        

Reply Children
Related