Background Timers

Get time in uS since powerup int64_t esp_timer_get_time() esp_timer_get_time() returns 64-bit time since startup, in microseconds. int64 = 292,471 years before overflow at uS resolution! Unlike gettimeofday function, values returned by esp_timer_get_time() start from zero after startup of the chip wakes up from deep sleep and do not have timezone or DST adjustments applied.    

Read More

Hardware Timers

ESP32 has 4 individual hardware timers, arranged as 2 timers x 2 timer groups. All 4 are 64-bit generic timers based on 16-bit prescalers and 64-bit auto-reload-capable up / down counters. Resources https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/timer.html CMakeLists.txt REQUIRES Ensure the following is added to the REQUIRES section of your CMakeLists.txt file in the \main folder: Example using Timer […]

Read More

.Interrupts General

What can you do in interrupts In ISR functions you can do only simple thing, not time consuming operations. Disable interrupts You can suspend interrupts and context switches by calling  portDISABLE_INTERRUPTS and the interrupts on that core should stop firing, stopping task switches as well. Call portENABLE_INTERRUPTS after you're done

Read More

Creating tasks

TaskScheduler vTaskStartScheduler(); //<<<This FreeRTOS call is not required as the scheduler is already started before app_main() call Create New xTask Tasks should never return (i.e. be a continuous loop). xTaskCreate( [pointer to the function which will execute when the task is scheduled to run], [descriptive name for the the task, up to 16 chars, mainly […]

Read More

.Using the I2C interface

I2C Pins Typically you can use any GPIO: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/i2c.html To confirm, see the S# series datasheet for the ESP device you are using > Peripheral Pin Configurations Resources https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/i2c.html https://github.com/espressif/esp-idf/tree/master/examples/peripherals/i2c I2C Address Set as normal byte address including RW at bit 0.So 0b01101000 is set as 0x68, not (0x68 >> 1) I2C Master Example write, […]

Read More

.IO Pin Control General

Documentation https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/gpio.html Input Pins Combined method Individual functions method Output Pins Disable Pins

Read More

Delays

Delay in mS The RTOS tick period is (by default) 10ms N.B. vTaskDelay is no good for small mS delays. It is based on the RTOS tick rate. If you select a value < portTICK_PERIOD_MS you may get a zero delay or you may get a delay of portTICK_PERIOD_MS (so 10mS). We’ve also found instances […]

Read More

Making Eclipse work properly

Eclipse defaults are different to lots of IDE’s we use on Windows, here’s how we fix eclipse… Open eclipse preferences: Menu > Window > Preferences General > Workspace > Build > Save automatically before build General > Keys To Upper Case – Ctrl + Shift + U To Lower Case – Ctrl + Shift + L […]

Read More