fixed delays for esp32 #16
Closed
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
esp32 uses FreeRTOS delay with default 10 ms timer tick., so ticks are rounded down to 10 ms tick intervals and a tick can take 0 milliseconds worst case. So the reset sequence was invalid as the delays were too short. I used a longer delay for the reset sequence and used micro second delays for other functions. Some functions do not have a CMD_DELAY listed in the datasheet and work fine without a delay. In fact readFillArray is too slow with a delay so it clogs up the FIFO.
You have to continuously check the FIFO or else it will fill up and first the values will lag behind and then you will get invalid values because there are FIFO errors. I haven't found a way to avoid this. I've created an example which avoids this problem by reading it quickly.
I have only tested this on the ESP32. So be sure to test it on other Arduinos.