libuarte and sdcard spi ?

Dear Members,

I run 3 devices,

GPS on libuarte1

LCD on SPI2

Sdcard on SPI 1,

I'm using ANT and softdevice 340,

When I run LCD and SDcard outside the main loop, it's working ok,

by the time it's inside the main loop, it crashes with libuarte1,

Code :

									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, //originally 28 Sept 2021
					  //.baudrate   = NRF_UARTE_BAUDRATE_38400,
            .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);
 /******************SDCARD  Sequence****************/   
 
			 
						NRF_SPI2->ENABLE = 0; //ILI9341 off
		          nrf_delay_ms(100);
			        NRF_SPI1->ENABLE = 1; //SDcard on
								
								fatfs_example();
								nrf_delay_ms(100);
								
		  /******************SDCARD  Sequence****************/   					  					
            printf("\rRixtronix LAB GPS Query.... \r\n");		
						 nrf_delay_ms(2000);
						GPSNeo_Process();

Debug :

nfo> app: 
                                                                   

isting directory: /
                                                          

   9550  RIXTRO.TXT<info> app: Writing to file RIXTRO.TXT...
                 

nfo> app: 50 bytes written.
                                                  

nfo> app: LOOP Rixtronix LAB.


rror> app: SOFTDEVICE: ASSERTION FAILED
     

                                                


                                                                             

nfo> app: Support us by subscribing,thanks...
                                


                                                                             

nfo> app: Initializing disk 0 (SDC)...
                                       

nfo> app: Capacity: 30436 MB
                                                 

nfo> app: Mounting volume...
                                                 
<error> app: ERROR 0 [NRF_SUCCESS] at ..\..\..\..\..\..\..\..\components\librari

\libuarte\nrf_libuarte_async.c:230
                                           

 at: 0x0004877B
                                                              

rror> app: End of error report

Any ideas on resolving it ? thanks

Parents Reply Children
  • Hi Rixtronix,
    I don't see a problem with the NRF_LIBUARTE_ASYNC_DEFINE setup. Do you still have an issue with the freeing length of the buffer ? 
    I would strongly suggest to try adapting the libuart example to your system for testing before you move to the communication with GPS. (Copy the same loopback code, only modify NRF_LIBUARTE_ASYNC_DEFINE() to match with your setup) 

  • Hi Hung Bui,

    Thanks for the reply,

    I changed these lines

     ret = nrf_libuarte_async_tx(p_libuarte,p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
                if (ret == NRF_ERROR_BUSY)
                {
                    buffer_t buf = {
                        .p_data = p_evt->data.rxtx.p_data,
                        .length = p_evt->data.rxtx.length,
                    };
    
                    ret = nrf_queue_push(&m_buf_queue, &buf);
                    APP_ERROR_CHECK(ret);
                }
                else
                {
                    APP_ERROR_CHECK(ret);
                }

    to :

      case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
                       GPS_CallBack();

    void	GPS_CallBack(void)
    
    {
    	
    	GPS.LastTime=nrf_systick_val_get(); //originally
    	 
    	
    	if(GPS.rxIndex < sizeof(GPS.rxBuffer)-2)
    	{
    		GPS.rxBuffer[GPS.rxIndex] = GPS.rxTmp; //originally
    		 
    		GPS.rxIndex++;
    		memcpy((void *)line_buffer_GPS, GPS.rxBuffer, GPS.rxIndex); 
    			
    	}
       nrf_libuarte_async_rx_free(&libuarte1, (uint8_t *)&GPS.rxTmp, 1);
    	 
    	
    }
    

    The callback was working with different MCU,

    Any suggestions ?

    Thanks

  • Hi , 

    How many bytes do you receive when NRF_LIBUARTE_ASYNC_EVT_RX_DATA occurs ? You need to check the p_evt->data.rxtx.length to know the number of byte you received. I assume it's more than 1 byte   ? 


    I can see you still calling nrf_libuarte_async_rx_free(&libuarte1, (uint8_t *)&GPS.rxTmp, 1); with just one byte in length. 

    Please try to get to know how the libuarte works before using it. 

Related