wafa_ath
wafa_ath
DIIDevHeads IoT Integration Server
Created by Enthernet Code on 9/13/2024 in #iot-cloud
Why isn't the LED responding to voice commands in my MicroPython code?
Hi @Enthernet Code modify your SPI_PeripheralControl function to use a read-modify-write operation:
void SPI_PeripheralControl(SPI_RegDef_t *pSPIX, uint8_t EnOrDi)
{
uint16_t temp = pSPIX->CR1;
if(EnOrDi == ENABLE)
{
temp |= (1 << SPI_CR1_SPE);
}
else
{
temp &= ~(1 << SPI_CR1_SPE);
}
pSPIX->CR1 = temp;
}
void SPI_PeripheralControl(SPI_RegDef_t *pSPIX, uint8_t EnOrDi)
{
uint16_t temp = pSPIX->CR1;
if(EnOrDi == ENABLE)
{
temp |= (1 << SPI_CR1_SPE);
}
else
{
temp &= ~(1 << SPI_CR1_SPE);
}
pSPIX->CR1 = temp;
}
This approach preserves other bits in the CR1 register while modifying only the SPE bit.
4 replies