Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By disideris
#65859 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?
User avatar
By rudy
#65862 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.
User avatar
By martinayotte
#65888 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.