-
I don't know the maximum speed of the Pico, but UART may be a bottleneck.
I haven't used that IMU, but looks like you can read multiple bytes in a single operation. That definitely will be faster.
The number of characters you execute has a direct effect on execution speed. For example
return SPI1.send([addr|READ,0x00],ss)[1];
is almost surely faster than
result=SPI1.send([addr|READ,0x00],ss)[1]; return result;
Related to that,
read_FIFO(FIFO_DATA_OUT_H,FIFO_DATA_OUT_L,ss)
is "terribly long" , but you can try minification and pretokenisation, as those speed up execution, and most likely you won't have to manually shorten function and variable names.
Hi Robin,
Thank you very for replying and helping.
I set them to setInterval and that error does not occur anymore.
I believe I am using the hardware SPI and this is my SPI set up
The read time is to read the timestampes from the IMU, which is part of the data collection from the IMU.
the readtime Code looks like this:
I checked the time needed to collect one set of data is fixed at .029ms, IMU generate each set of data at 833Hz = 1/833 ~=0.0012, the time for the IMU to generate one set the data is a lot faster than the program excution. I think the problem is when the FIFO is full, the pattern will be messed up.
I am not very sure why PICO takes so long to read a set of data. I tried to look up the default system clock rate and it seems 84MHz already based on this E.setClock(Correct me if I am wrong), is there a way to improve the program execution/reading speed?
Changed version code
Output:
Spi: