Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Increased User Data causes disconnection

Increased User Data causes disconnection

Anonymous
Not applicable
Question: When I increase the user data in DVK v1.6 PSoC firmware the link will frequently be lost. How can this be fixed?

 

Answer:

 Below is a patch for the DVK (PSoC firmware) to fix a receive buffer overflow (link loss) firmware issue with v1.6.

  1.   Open all "radio.c" files under directory "...\Firmware\Source Code\..."
  2.   Replace radio_receive() function on line 372 with the following:

UINT8 radio_receive(UINT8 buffer_length, UINT8 *rx_buffer, UINT8 *valid_buffer, UINT16 timeout)
{
   UINT8 irq_source;
   UINT8 radio_state;
   UINT16 loop_counter = 0;

   radio_state = (spi_radio_get(REG_CONTROL));

   if ((radio_state & RX_ENABLE) != RX_ENABLE) {
      radio_receive_on();
   }
  
   rx_data_length = 0;

   // don't break out of the loop mid-packet..
   while ((loop_counter < timeout) || (rx_data_length != 0)) {

      // poll for a Radio Module interrupt, interrupts are self clearing
      // when the appropiate status register is read 
      if(LS_IRQ_ASSERTED) { 
         irq_source = spi_radio_get(REG_RX_INT_STAT);
         
         if(irq_source & RX_FULL_A) {
            if (rx_data_length < buffer_length) {
               *rx_buffer = spi_radio_get(REG_DATA_RX_A);
              
               // don't read the valid register if it is all valid
               if( irq_source & RX_VALID_A ) {
                  *valid_buffer = 0xFF;
               }
               else {
                  *valid_buffer = spi_radio_get(REG_VALID_RX_A);
               }
        
               // filter out bad bytes and don't overwrite the globals
               if((*valid_buffer >= 0x0F) || (rx_data_length > 0)) {
                  rx_data_length++;
                  loop_counter = 0;

#ifdef RADIO_CHECK_FOR_ACK 
                  if (((data & 0xF0) == 0x50) && (rx_data_length == ACK_LEN)) {
                     break;
                  }
#endif
                  rx_buffer++;
                  valid_buffer++;
               }
            } 
            else {
               // buffer overflow... clear data register...exit receive mode
               spi_radio_get(REG_DATA_RX_A);
               rx_data_length = 0;
               break;
            }
         }

         if(irq_source & RX_EOF_A) {
            if (rx_data_length != 0) {
               break;
            }
         }

         if(irq_source & RX_OVER_A) {
            loop_counter = 0;
         }
      } 
      else {
         ++loop_counter; // only increment loop_counter for each 10us delay...
         TIMER_DELAY_10_USEC();
      }
   }

   if ((radio_state & RX_ENABLE) != RX_ENABLE) {
      radio_off();
   }

   return rx_data_length;
}

0 Likes
235 Views
Contributors