Terminal dropping messages

Good afternoon, 

I am trying to send some analog data from a function generator to my nRF7002 DK and visualize the output in Putty. I use printk to print the values and I see that I have a lot of messages being dropped (I constantly get  --- 17 messages dropped --- for some applications and a lot more for others). Can you please help me increase the size of the print buffer? Or there might be another problem?

Thank you. 

  • My SAADC buffer is 8000. I tried 50 us, 50ms 

  • Can you share your sample code? Or atleast from which function(s) you are printing from? It sounds like you are in interrupt priority and printing.

     

    Kind regards,

    Håkon

  • Of course, here is the function where I am printing: 

    static void saadc_event_handler(nrfx_saadc_evt_t const * p_event)
    {
        nrfx_err_t err;
        switch (p_event->type)
        {
            case NRFX_SAADC_EVT_READY:
            
               /* STEP 6.1 - Buffer is ready, timer (and sampling) can be started. */
                nrfx_timer_enable(&timer_instance);
    
                break;                        
                
            case NRFX_SAADC_EVT_BUF_REQ:
            
                /* STEP 6.2 - Set up the next available buffer. Alternate between buffer 0 and 1 */
                err = nrfx_saadc_buffer_set(saadc_sample_buffer[(saadc_current_buffer++)%2], SAADC_BUFFER_SIZE);
                if (err != NRFX_SUCCESS) 
                {
                LOG_ERR("nrfx_saadc_buffer_set error: %08x", err);
                return;
                }
    
                break;
    
            case NRFX_SAADC_EVT_DONE:
    
                /* STEP 6.3 - Buffer has been filled. Do something with the data and proceed */
    
                int16_t current_value; 
                for(int i=0; i < p_event->data.done.size; i++){
                    current_value = ((int16_t *)(p_event->data.done.p_buffer))[i];
    
                    printk("%d, ", current_value);
    
                }
    
                break;
    
            default:
                LOG_INF("Unhandled SAADC evt %d", p_event->type);
                break;
        }
    }

    and I`ll also attach my project, in case it is helpful for you. 

    current_code.zip

    This version does not contain any of the k_sleep that I was mentioning, becasue they did not help anyway. 

    Thank you so much!

  • Hi,

     

    You are printing in an interrupt handler, which will block the system (logger) from running.

    Try printing your saadc buffer from main context instead by setting a flag or similar in saadc_evet_handler() function.

     

    Also; remember that your UART is running at 115k2 baud, which isn't that fast. Printing 8k buffers will take some time, and you risk underrun due to the serial interface being too slow compared to your saadc sampling.

      

    Kind regards,

    Håkon

Related