This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Burst transmission attempt return a 4016 error (channel closed)

Hello, 

I'm developing a master device which requires 512Hz of sampling using the ADC, triggered by RTC0 via PPI. I'm trying to send these data using ANT but, since transmission would require at least 170Hz broadcast is not enough, so burst transmission would be perfect.

int main(void)
{
    softdevice_setup(); 
    ant_advanced_burst_setup(); //this set the channel as master 0x10, channel period to 4096 for 8Hz transmission and init&opens the channel
    utils_setup(); //for App_timer and pwr_mngmt_init
    rtc_config(); 
    ppi_init();     //bridge RTO0 and SAADC
    saadc_init();   //set adc to take 128B(64samples) and trigger an interrupt when data is ready
rtc_start();        //start the count and the sampling
    
    // Enter main loop
    for (;;)
    {
        nrf_pwr_mgmt_run();
    }
}

Setting is the same used in the sample code ant_advanced_burst but once everything is set, the first ADC buffer is filled (64B) and the send function is called by its interrupt  (send 136B in a 5*24B+16B sequence, every time a buffer is ready) this results in a 4016 error. I'm using antwareII to receive the data.

void saadc_callback_handler(nrf_drv_saadc_evt_t const * p_event){

     if(p_event -> type ==  NRF_DRV_SAADC_EVT_DONE){    // check if the sampling is done and we are ready 
          ret_code_t err_code;                          // a variable to hold errors code
          err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAMPLE_BUFFER_LEN); //switch buffers
          
          APP_ERROR_CHECK(err_code);                    // check for errors
          memset(val, 0, TX_BUFFER_LENGTH);

          val[0]=CHAN_ID_DEV_NUM;                       //first bit transmitted is the device number 
          val[1]=(uint8_t)((counter)&0xFF00)>>8;          //two B of counter to keep track of data 
          val[2]=(uint8_t)(counter)&0xFF;
          counter++;
          // we have 5B which can be used for something useful
          uint8_t i=8, k=0;
          do{
              val[i++]=((p_event->data.done.p_buffer[k])&0xFF00)>>8;
              val[i++]=(p_event->data.done.p_buffer[k])&0xFF;
              k++;
          } while(k<64); //this cycle puts the 16b buffer filled by the ADC in the 8b rrray used to transmit data via ANT

          ant_send();  //this functions is supposed to send the data
          
      }
      else  
          return;
}



 void ant_send(void){
      uint32_t err_code;
      uint8_t  burst_segment = BURST_SEGMENT_CONTINUE;
      uint8_t  bytes_to_send = BURST_BLOCK_SIZE;
      
      do{
          if (segment>=5){
              // This is the last block
              burst_segment |= BURST_SEGMENT_END;
              bytes_to_send  = TX_BUFFER_LENGTH-m_bytes;
          }

          else if (segment>0 && segment<5)
              burst_segment = BURST_SEGMENT_CONTINUE;

          else if (segment==0)    //first package of 24B to 
              burst_segment = BURST_SEGMENT_START;

        while(burst_wait)
            ;
        err_code = sd_ant_burst_handler_request(ANT_CHANNEL_NUM, bytes_to_send, val+(segment*24), burst_segment);
        APP_ERROR_CHECK(err_code);
        segment++;
        m_bytes += bytes_to_send;
        
    } while (segment<5);
    segment=0;
    m_bytes=0;
}

in debug mode I checked that every command is done correctly, and the channel is opened, the ADC do its job and calls the function. has someone some suggestions? 

thx and have a nice day.

Parents
  • I will open a thread in the forum thank you,

    if I add a delay of at least 10ms right after the channel setup, the error is no more 4016, but i have a 4020 which suggests an error in the sequence of burst transmission, is it ok to put a delay after the channel opening?

    since I'm trying to transmit a payload of 136B at every interrupt ( every 64 samples an interrupt is triggered, having 512sps gives an interrupt every 125ms), is the transmission speed enough? I mean, a single burst is 1088b, let's say we have 100ms of timeslot, do 52832 transmit 1088b in a burst during this time?

    I moved the "transmission request" to the main function anyway, thank you for your suggestion.

Reply
  • I will open a thread in the forum thank you,

    if I add a delay of at least 10ms right after the channel setup, the error is no more 4016, but i have a 4020 which suggests an error in the sequence of burst transmission, is it ok to put a delay after the channel opening?

    since I'm trying to transmit a payload of 136B at every interrupt ( every 64 samples an interrupt is triggered, having 512sps gives an interrupt every 125ms), is the transmission speed enough? I mean, a single burst is 1088b, let's say we have 100ms of timeslot, do 52832 transmit 1088b in a burst during this time?

    I moved the "transmission request" to the main function anyway, thank you for your suggestion.

Children
Related