Dear Concern,
Is any reason behind this delay, as it is not working without delay?
Dear Concern,
Hi,
Exactly where did you apply the delay? Could you show in the code?
External Module was not configured properly without minimum nrf_delay_ms(10).
What do you mean by this?
I don't think this is a question that should be directed to Nordic unless you only observe this with the Nordic MCU.
regards
Jared
Hi Jared,
Hi,
As long as the data being sent on MOSI is correctly and is transmitted in expected time I think that the issue is probably related to the LSM6DSO module. What exactly happens if you don't include the delay? Do you see the expected data being transmitted from the nRF52? How does the LSM6DSO respond? I'm trying to get a better understanding of what the issue really is. Please include traces from a logic analyzer or similar where the difference is highlighted.
Also, what do you do in the code after you've started the transfer?
Jared
Something to check, as this requirement for a delay often indicates a buffer inadvertently being placed on the stack and overwritten before the data has been completely used. In a function like this:
void mySpiStuff(void)
{
uint8_t ctrl3_c_accelerometer[] = {1,2,3,4,5};
if(nrf_drv_spi_transfer(&spi, ctrl3_c_accelerometer, sizeof(ctrl3_c_accelerometer), NULL, NULL) != NRFX_SUCCESS)
{
error = 12; return error;
}
//nrf_delay_ms(10); // Minimum delay required
return ok;
}
void myOtherStuff(void)
{
uint32_t stuff[8];
.. blahBlah
}
void main(void)
{
.. blahBlah
mySpiStuff();
myOtherStuff();
}
The problem is myOtherStuff() runs before the SPI transfer is complete, which clobbers the data in ctrl3_c_accelerometer before that data has completed the journey to the accelerometer. The fix is very simple, make ctrl3_c_accelerometer static, which moves the location off the stack and into safe memory:
uint32_t mySpiStuff(void)
{
static uint8_t ctrl3_c_accelerometer[] = {1,2,3,4,5}; // <== use static!
if(nrf_drv_spi_transfer(&spi, ctrl3_c_accelerometer, sizeof(ctrl3_c_accelerometer), NULL, NULL) != NRFX_SUCCESS)
{
error = 12; return error;
}
return ok;
}
If it's any help, experienced programmers can make this mistake, and it makes a good interview question.