azz-zza wrote on Friday, September 13, 2019:
Hello,
the “blinky” works, until i try to implement it using tasks. BTW i’m running esp32doit-devkit-v1 with espressif32 framework.
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#include "driver/gpio.h"
#include "nvs_flash.h"
#define BLINK_GPIO GPIO_NUM_2
portTickType c_1000ms = 1000 / portTICK_RATE_MS;
extern "C"
{
void app_main(void);
}
void blinky(void *pvParameter)
{
gpio_pad_select_gpio(BLINK_GPIO);
/* Set the GPIO as a push/pull output */
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
while (1)
{
gpio_set_level(BLINK_GPIO, 0);
vTaskDelay(c_1000ms * 2);
gpio_set_level(BLINK_GPIO, 1);
vTaskDelay(c_1000ms);
}
vTaskDelete(NULL);
}
void app_main(void)
{
vTaskDelay(c_1000ms * 2);
printf("Hello world!\n");
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
TaskHandle_t xHandle = NULL;
BaseType_t xReturned;
if (xReturned != pdPASS)
{
printf("Error in TaskCreate");
esp_restart();
}
vTaskStartScheduler();
}
the output is :
␛[0;32mI (0) cpu_start: Starting scheduler on APP CPU.␛[0m
Hello world!
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400d1b1f PS : 0x00060430 A0 : 0x800d1227 A1 : 0x3ffb1b00
A2 : 0xa5a5a5a5 A3 : 0x000000ff A4 : 0x00000042 A5 : 0x00000000
A6 : 0x3ffb1c70 A7 : 0x3ffb1c50 A8 : 0x0000007e A9 : 0xfffffffa
A10 : 0x00000001 A11 : 0xffffff01 A12 : 0xffffff43 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x3ffb1bf0 SAR : 0x00000006 EXCCAUSE: 0x0000001c
EXCVADDR: 0xa5a5a5b1 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Backtrace: 0x400d1b1f:0x3ffb1b00 0x400d1224:0x3ffb1b60 0x400d14ad:0x3ffb1cb0 0x400d10c0:0x3ffb56e8
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
i’ve been looking in FREERTOS guide and in “Internet of Things with SP32” example… clearly missing something essential.
Thank you.