-->
Page 1 of 1

Missing SPI interrupts

PostPosted: Fri May 12, 2017 6:37 am
by disideris
Hi there,

I have an LPC uC which i use as SPI master that is connected with an esp8266 (spi slave).

For esp I am using arduino esp framework and wrote a sketch to handle spi interrupts.
I am using the SPISlave library https://github.com/esp8266/Arduino/tree ... s/SPISlave.

Inside setup() there is the interrupt handle routine of SPI Slave library (SPISlave.onData).
Inside SPISlave.onData i set a flag true. So every time i get an spi interrupt spiflag is true.

Inside loop() i check if the spi flag is true do some actions and restore spi flag to false.
These actions are to send the received spi data through http rest POST to a server. So there must be some latency here.

When i manually send spi data from master(LPC) to slave(esp) there is no problem. Interrupts occur and spi data are sent through http request.
But when code from master(LPC) sends continuously data through spi i miss interrupts.
I have checked that i miss interrupts.

Any ideas how to overvome this issue?

Can i use some kind of queue to buffer spi data so that i dont miss them?
Any idea?

Re: Missing SPI interrupts

PostPosted: Fri May 12, 2017 11:54 am
by rudy
I don't have an answer for you. But what I would do is set an output when you set your flag, and clear when you clear the flag. Then I would look at the timing with a logic analyzer or digital scope. If you don't have access to those then I would get the millis time on each transition.

Re: Missing SPI interrupts

PostPosted: Sat May 13, 2017 8:32 am
by martinayotte
You probably need some kind of RingBuffer, where the SPI interrupt fill in the data, and use this buffer in main loop by filling out the data to be sent by your HTTP POST.