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. 

Parents Reply Children
  • Hey! 

                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);
               
                }
    I am using this function to print my values. I tried adding a K_SLEEP in the for loop and outside, but I still get only 10% of my values. Which is the best way to print big arrays?
    Thank you!
    Kind regards, 
    Raluca
  • Hi,

     

    I tried adding a K_SLEEP in the for loop and outside,

    How large is the array that you're printing? and what was the k_sleep that you tried? k_msleep(1) should be sufficient per half-word.

     

    Kind regards,

    Håkon

  • 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!

Related