-
Mon 2019.11.04
Thank you for posting the upgraded snippets @user101931
Big DISCLAIMER here - I didn't research the parts here, nor even what the SPI traffic is doing. One line stuck out so just provided a quick untested response
'I believe I am using the hardware SPI '
Yes. Based on the setup function snippet, as there isn't an assignment to a var used to declare the software SPI pinout such as
var spi = new SPI(); spi.setup({mosi:B5, miso:B4, sck:B3}); spi.write([1,2,3,4])
and the use of Espruino defined SPI1 SPI2 SPI3 hardware constants.
The following reference from image 3 from #14I like the new
extraction()
function.I do see a possible area of contention. L18 has an argument (the value of the interval parameter) for
setInterval()
that is waaaaaay out of range. I did some quick look up, but can't locate the range of the low end, although the Espruino docs from #13 link do indicate the upper end. As the value needs to specify msec, experience tells me that approaching a value of 20 may start to show signs of struggle. Normal ranges, 30sec down to 20msec, would equate to a value in the 30000 - 20 range.
My S.W.A.G. guess is that the decimal value is getting rounded to an integer, and that is still too small a value in an attempt to fetch the SPI payload. Shouldn't this be more like a sampling request every second or so, and the SPI traffic from the device would then be able to respond timely? This is akin to having an attempt to fetch that is 100-1000 times faster than the data that actually is attempted to be fetched. The requests are queueing up and eventually running out of room/time to perform the actual task. As I said, just a quick S.W.A.GG'd response. That would explain why a few accurate lines of data do in fact get through, then the whole works gets bogged down. (I'll have more time to dig deeper this weekend)for @AkosLukacs
'is almost surely faster than'
result=SPI1.send([addr|READ,0x00],ss)[1]; return result;
One reason might have been to enable the debugger to return a value for human viewing, before actually returning that value. I fall victim to that requirement and sometimes overlook and catch during code cleanup. Point well taken though.
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: