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

  • I see. There should be no difference at all. You just need to ensure that you do not try to use peripherals that are used by the SoftDevice or other libraries. If you still struggle, perhaps you can share your code so that I can see?

  • Which part of code do you want to see ?

    I make a copy of main function, hang on...

    int main(void)
    {
    	ret_code_t err_code;
    	float convert;
    	
    	 // This function contains workaround for PAN_028 rev2.0A anomalies 28, 29,30 and 31.
        
       uint32_t tick;			
    		
    	  
        log_init();
        utils_setup();
        softdevice_setup();
    	    //**Init I2C and EEPROM before ant started, in order toclear EEPROM before sensor start TEST**
    	    ssd1306_init_i2c(SSD1306_CONFIG_SCL_PIN, SSD1306_CONFIG_SDA_PIN);
    			eeprom_cmd_clear_distance(); 
    	    //initialize time for distance saving
    			m_speed_calc_data.acc_evt_time=0; 
    	
        profile_setup();
    	
    	  create_timers();
    	 
    	  /* Init systick driver */
        nrf_drv_systick_init();
    	 
    	 app_timer_start(m_repeated_timer_id, APP_TIMER_TICKS(1000), NULL);
    	   //SSD1306 Code
    	    // ssd1306_init_i2c(SSD1306_CONFIG_SCL_PIN, SSD1306_CONFIG_SDA_PIN);
    	   ssd1306_begin(SSD1306_SWITCHCAPVCC, SSD1306_I2C_ADDRESS, false);
    	   ssd1306_clear_display(); //Rixtronix LAB
    		    //nrf_delay_ms(1000);
            ssd1306_display();
    	      nrf_delay_ms(500);
    	      NRF_LOG_INFO("--- testdrawline ---");
            //
            ssd1306_draw_circle(SSD1306_LCDWIDTH / 2, SSD1306_LCDHEIGHT / 2, 30, WHITE);
    	       nrf_delay_ms(1000);
            ssd1306_display();
    	        nrf_delay_ms(1000);
               //convert int32_t to float
             ieee_float();	
         				nrf_delay_ms(1000); 
    			
    			 /**********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*****/
    

  • is my "create_timers();" crashed with libuarte1 timer ?

  • I used timer3 and it's now giving me a proper response,

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

    Thanks for helping, I'll keep posting and share the progress....thanks again..

  • Hi,

    I don't know, really. I need to see all to get an overview. There is one thing we can try first, though. Referring to:

    RixtronixLAB said:

    and the app gives me  :


    rror> app: Fatal error
                                                           

    arning> app: System reset

    If you define DEBUG and DEBUG_NRF in your project settings (if you use a SES SDK project it should be enough to just select the "Debug" target), then you will get much more information in the error message. You should see where the fatal error comes from, and why. With that it should be much easier to pin-point the problem.

Related