I'm somewhat puzzled about freerots' memory model - I wasn't able to finde a suitable reference, yet.
To illustrate my confusion, I modified the example blink app, to read data from the heap:
Code: Select all
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"
#define BLINK_GPIO CONFIG_BLINK_GPIO
static int freq = 1000;
void blink_task(void *pvParameter)
{
gpio_pad_select_gpio(BLINK_GPIO);
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
while(1) {
gpio_set_level(BLINK_GPIO, 0);
vTaskDelay(freq / portTICK_PERIOD_MS);
gpio_set_level(BLINK_GPIO, 1);
vTaskDelay(freq / portTICK_PERIOD_MS);
}
}
void app_main()
{
xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
while(1) {
vTaskDelay(5000 / portTICK_PERIOD_MS);
freq = 500;
vTaskDelay(5000 / portTICK_PERIOD_MS);
freq = 1000;
}
}
I'm not sure, if it this worked by coincidence (i.e. both task are running on the same core) or if the memory model of FreeRTOS guarantees this.
I.e. when programming Java, the "volatile" keyword instructs the JVM not cache a variable. Is there something like volatile in FreeRTOS? Do you know a nice reference on the FreeRTOS memory model?
Thanks in advance,
yanosz