Data Logging

Hi,I am using NRF5340 ,I want to log data of 2 channels of mic with sampling rate of 16000 but while logging I am receiving "120 messages dropped" and with some random numbers if I change configurations.

CONFIG_I2S=y
CONFIG_I2C=y

CONFIG_LOG_PRINTK=y

CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG=y
CONFIG_LOG_MEM_UTILIZATION=y

CONFIG_LOG_MODE_OVERFLOW=n
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=65536
CONFIG_LOG_BUFFER_SIZE=65536

CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048

Parents
  • Hi,

     

    How often are you logging? Ie. what is the throughput?

    If you log each sample at 16 KHz, and also convert it to ASCII string, it is likely that this will take some time. And if your firmware is blocking the logger thread from running in longer intervals, it will overflow after a while

     

    Kind regards,

    Håkon

  • static void copyBuffer(int32_t *Buff_In,int16_t *Buff_Out,uint16_t number_of_samples)
    {
    for(int i = 0; i < number_of_samples; ++i)
    {
    Buff_Out[i]= Buff_In[i]>>16;
    printk("%d\n",Buff_Out[i]);
    }
    }.I am using this logic each data of 32 bit is shifted to 16 bit and it prints,I am logging continuous data coming from i2s_buf_read function of buffer 244.
  • Hi,

     

    It does sound like you are missing data, especially on '14' and possibly on '7'.

    Have you considered using usb as the loopback instance instead?

     

    Also, if you use an external debugger (JLink Base compact for instance), you can increase the SWD speed, for more throughput on the actual reads from the JLink debugger itself.

     

    Kind regards,

    Håkon

  • Have you considered using usb as the loopback instance instead?

    what does it refer?

    Also, if you use an external debugger (JLink Base compact for instance), you can increase the SWD speed, for more throughput on the actual reads from the JLink debugger itself

    I am using same jlink  base compact at max speed even though i am getting same audio mismatch.Audio is not missing at end it's missing between the data.If it's sampling at 16000 ,how data logging is missing in between,it should go one by one?I am not sure how data log works.I am using SEGGER_RTT_PRINTF.I thought to use SEGGER_RTT_WRITE ,I am getting data like(

    ù
    ûù
    Æù
    ºù
    ¾ù
    4ù) but converting it to wave getting only noise.
    static void copyBuffer(int32_t *Buff_In,int16_t *Buff_Out,uint16_t number_of_samples)
    {
    	int i=0;
    	
    	for( i = 0; i < number_of_samples; i++) 
    	{
    		Buff_Out[i]= (Buff_In[i]>>16);
    		
    		// printk("%hx %hx\n",bellMicData,ancMicData);
    		 SEGGER_RTT_printf(0,"%d\n",Buff_Out[i]);
     		// SEGGER_RTT_Write(0,(const void*) &Buff_Out[i], 2);
    	}
    	// SEGGER_RTT_Write(0,&newline,1); 
     }
    while rearding one mic i didnt got issue,on logging two only i am getting issue
  • Hi,

    Kashyap23 said:
    what does it refer?

    To use USB with an audio class to send/receive audio.

     

    I think you're sending it as raw data now:

    Kashyap23 said:

    am using same jlink  base compact at max speed even though i am getting same audio mismatch.Audio is not missing at end it's missing between the data.If it's sampling at 16000 ,how data logging is missing in between,it should go one by one?I am not sure how data log works.I am using SEGGER_RTT_PRINTF.I thought to use SEGGER_RTT_WRITE ,I am getting data like(

    ù
    ûù
    Æù
    ºù
    ¾ù

    echo -n "ùûùÆùwùmù^ù?ùeùºù¾ùcù7ùTùPù" | xxd
    00000000: c3b9 c3bb c3b9 c386 c3b9 77c3 b96d c3b9  ..........w..m..
    00000010: 5ec3 b93f c3b9 65c3 b9c2 bac3 b9c2 bec3  ^..?..e.........
    00000020: b963 c3b9 37c3 b954 c3b9 50c3 b9         .c..7..T..P..
    

     

    You need to remove the delimiter \n to listen back to the data.

     

    Kind regards,

    Håkon

  • yes,I am trying with raw as I am missing data.By using raw data converting to wav file giving noise.I followed your step and logged data.

    rwData.txt

  • What I would recommend is that you write known values to RTT, and see what is present in the file afterwards.

    For instance sending several values like, val=0x11223344 and val=0x12345678, and see what is present in the stored file on the PC afterwards.

     

    Kind regards,

    Håkon

Reply Children
  • yah thanks Alseth,now I able to convert raw data to wav file but converting to integers and logging leads to data loss.I was not able to solve that.

  • Are you certain that it is the logging function that is corrupting/missing data, and not the I2S DMA process that is overwriting the buffers before you're copying them or in the middle of that sequence? Or creating a minimalistic example with little / no other functions, just sampling of a microphone?

    DMA can be a bit of a struggle to debug, especially if there is a timing skew (caused by ISRs or other threads) in the copy sequence.

     

    Instead of processing each sample individually, then RTT print, could you try to copy it into a larger buffer, then print the whole buffer?

    static void copyBuffer(int32_t *Buff_In,int16_t *Buff_Out,uint16_t number_of_samples)
    {
    	int16_t print_buf[sizeof(MAX_SIZE)];
    	for(int i = 0; .....) { /*copy int and shift -> int16_t */ }
    	my_print_func(print_buf, number_of_samples*sizeof(int16_t));
    }

      

    Kind regards,

    Håkon

Related