I am asking this since the Arduino-IDE up to the recent one (1.8.9) has a serious problem (a bug, at least for me) with the UNDO function, screwing up the code when used, occasionally, so it can't be used.
https://forum.arduino.cc/index.php?topic=609254.0
So I consider to come back to B4R...
I am using the ESP32. In the Arduino-IDE, I am using a timer-interrupt to get a position reading as fast as possible from a sensor attached to SPI (50µs works at present), so the void loop (almost) always knows the position and can react on that.
I read that interrupts are not implemented in B4R,(?).
Would the use of the timers in B4R be equivalent to using the timer interrupts in the Arduino-IDE?
https://forum.arduino.cc/index.php?topic=609254.0
So I consider to come back to B4R...
I am using the ESP32. In the Arduino-IDE, I am using a timer-interrupt to get a position reading as fast as possible from a sensor attached to SPI (50µs works at present), so the void loop (almost) always knows the position and can react on that.
B4X:
void IRAM_ATTR onTimer() {
portENTER_CRITICAL_ISR(&timerMux);
digitalWrite(CSB, LOW);
SPI.transfer(0xA1);
dataLSB = SPI.transfer(0x00);
digitalWrite(CSB, HIGH);
digitalWrite(CSB, LOW);
SPI.transfer(0xA2);
dataMSB = SPI.transfer(0x00);
digitalWrite(CSB, HIGH);
position = (dataMSB << 8) | (dataLSB);
position = (position >> 6)-90;
dacWrite(DAC_Channel_1, position);
portEXIT_CRITICAL_ISR(&timerMux);
// Give a semaphore that we can check in the loop
// xSemaphoreGiveFromISR(timerSemaphore, NULL);
// It is safe to use digitalRead/Write here if you want to toggle an output
}
Would the use of the timers in B4R be equivalent to using the timer interrupts in the Arduino-IDE?