cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in Spirit1 and Spirit2 (S2-LP) firmware library regarding Channel Spacing

maximevince
Associate

In Spirit1:

SpiritRadioGetChannel() is flawed:

uint32_t SpiritRadioGetChannelSpace(void)
{
  uint8_t channelSpaceFactor;
  
  /* Reads the CHSPACE register, calculate the channel space and return it */
  g_xStatus = SpiritSpiReadRegisters(CHSPACE_BASE, 1, &channelSpaceFactor);
  
  /* Compute the Hertz value and return it */
  //BUG: return (((uint64_t)channelSpaceFactor*s_lXtalFrequency)/CHSPACE_DIVIDER);
  return ((((uint64_t)channelSpaceFactor)*s_lXtalFrequency)/CHSPACE_DIVIDER);
  
}

And in S2-LP S2LPRadioComputeChannelSpacingRegValue() is flawed:

uint8_t S2LPRadioComputeChannelSpacingRegValue(uint32_t lChannelSpace)
{
  //BUG: return (uint32_t)(((uint64_t)lChannelSpace)<<15)/s_lXtalFrequency;
  return (uint32_t)((((uint64_t)lChannelSpace)<<15)/s_lXtalFrequency);
}
 
 

   There might be other places as well, but these are the two I encountered for now...

   It's clear this code is not tested, also examples on how to use channels are lacking.

   It's sad to see this is continuously the case with ST products and firmware libraries over the years...

0 REPLIES 0