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

Moderator: igrr

User avatar
By Nickkarl
#81993 Hi all! Im new to this forum aswell as with the ESP8266.

I've encountered a problem with the arduino SPI library in combination with the ESP8266.

I've read the SPI library should be compatible with the ESP. But some functions are appearantly missing. For instance SPI.usingInterrupt().
" 'class SPIClass' has no member named 'usingInterrupt' " is the message I get from the compiler. I would be really greatful if someone could tell me if there is a solution for such problems, and how to implement it?

The context is that I try to write sensor data to a SD card. Ive tried to call my writeToSD- funktion from the main loop, but for that to work I seem to need to reinitiate the SPI (SPI.begin() ) in my writeToSD() and turn interrupts off with noInterrupts() . But that is messing up my sample frequency of course. The strange thing is that the interrupt sequence seem to messing with the SPI in such way that I have to reinitiate it between the interrupts.

Thats when I though I could store the data from within the interrupt - function itself. But for that I need the SPI.usingInterrupt().

I would really appriciate any ideas how to solve this. And why are some functions missing in the arduino SPI-library, that are supposed to be there according to this link for example:
User avatar
By schufti
#82008 doing more than setting a flag in the isr is a nono with esp8266; watchdog is going to bite you.
keeping a loop timed sample rate with esp8266 is not something likely to happen as WiFi is periodicaly stealing random cycles.
User avatar
By Nickkarl
#82041 Thank you for the answer! I understand that the wifi - related interrupts fires off seemingly at random and that they are needed for keeping the wifi alive.

I've been given a code and my objective is to implement an microSD card and a routine for saving sensor data to it.

The sensor data is readed in this isr by I2C. The isr - routine takes about 800 us (micro seconds) and contains quite heavy code (for an isr) (that I didnt write). Is there any way to manipulate watchdog or to give the isr higher prio than the wifi-interrupts?

My guess is that this is impossible since the interrupts themselves disables other interrupts (setting the bit in some "SREG-equivalent" preventing other interrupts from occuring)? Is this the case?

Thank you again!
User avatar
By btidey
#82055 I think that is a bit restrictive.

It is more a case of ensuring that any ISR will always terminate within a reasonable time like 200uSec . I have many stable apps using ISRs which do significant work within the ISR like testing GPIO, checking time values, storing values in buffers and even running fast i2c operations.