2022-11-04 04:38 PM
I'm working with the SPIRIT1 (SPSGRFC-915) radio module, communicating over SPI, and using the provided SPIRIT1_Library. I am stuck after I preform the init sequence, the MC_STATE register keeps coming back with ERROR_LOCK 1, and STATE=2. I never enabled the RCO function so I'm not sure why ERROR_LOCK would be 1, and STATE=2 isn't a valid state on the datasheet, so I am very confused as for what is happening.
void init() {
SpiritSpiInit();
// restart the radio
SpiritEnterShutdown();
SpiritExitShutdown();
SpiritManagementWaExtraCurrent(); // To be called at the SHUTDOWN exit. It avoids extra current consumption at SLEEP and STANDBY.
// wait for the radio to enter the ready state
do
{
for (volatile uint8_t i = 0; i != 0xFF; i++); // delay for state transition
// gets stuck here
SpiritRefreshStatus(); // reads the MC_STATUS register
} while (g_xStatus.MC_STATE != MC_STATE_READY);
...
}
From debugging it looks it gets stuck in SpiritRefreshStatus' while loop
void SpiritRefreshStatus(void)
{
uint8_t tempRegValue[2];
/* Read the status both from register and from SPI header and exit when they match.
This will protect against possible transition state changes */
do
{
/* Reads the MC_STATUS register to update the g_xStatus */
g_xStatus = SpiritSpiReadRegisters(MC_STATE1_BASE, 2, tempRegValue);
}
while(!((((uint8_t*)&g_xStatus)[0])==tempRegValue[1] &&
(((uint8_t*)&g_xStatus)[1]&0x0F)==tempRegValue[0]));
}
I'm using the B-L475E-IOT01A2 board if it helps. Has anyone worked with this device before that can offer some pointers?