mouadmomo wrote on Wednesday, October 23, 2019:
hello
am developping the system using freeRTOS on arduino i have 4 tasks
the logo displayer task , the menu displayer task , the idle task and the sensing task
when i use the three first tasks everything works good when i use the forth taks which use the dht library the system block on the sensing part and stay do it infinitly
the my source code
void setup() {
// Set up functio parameters
initialize();
// cteating tasks for the operating system
xTaskCreate(dispLogo,"disp_logo", 200, NULL, 3, &TaskHandle_logo);
xTaskCreate(dispMenu,"disp_menu", 100, NULL, 2, &TaskHandle_menu);
xTaskCreate(taskIdle,"taskIdle", 100, NULL, 0, NULL);
xTaskCreate(sensingTask , "sensing", 50, NULL, 1, &TaskHandle_sensing);
dht.begin();
}
void taskIdle(void* pvParameters) {
while(1)
{
Serial.println(F("idle state"));
delay(50);
//vTaskDelay(50/portTICK_PERIOD_MS);
}
}
void dispLogo(void* pvParameters)
{
while(1)
{
// vTaskSuspend( TaskHandle_sensing );
mfunc.paint_logo(myGLCD) ;
Serial.println("the logo is displayed ");
//vTaskSuspend( TaskHandle_menu );
vTaskResume( TaskHandle_menu );
Serial.println("the logo is deleted ");
vTaskDelete(NULL);
}
}
void dispMenu(void* pvParameters)
{
while(1)
{
vTaskDelay(3000/portTICK_PERIOD_MS);
display_menu();
}
Serial.println("the end of the menu function ");
// evry second the process must start again to verify the dynamique display charachters
vTaskDelay(1000/portTICK_PERIOD_MS);
}
}
void sensingTask (void* pvParameters)
{
// vTaskDelay(4000/portTICK_PERIOD_MS);
// int sensingBuffer ;
// temHumiQueue = xQueueCreate (2,sizeof(sensingBuffer)) ;
while(1)
{
Serial.println("sensing temperature and humedity ");
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
int humidity = dht.readHumidity();
// seinding data into the queue buffer
//xQueueSend( temHumiQueue , (void*) sensingBuffer,(TickType_t)0);
// Read temperature as Celsius (the default)
/* int temperature = dht.readTemperature();
if (isnan(humidity) || isnan(temperature) ) {
Serial.println("Failed to read from DHT sensor!");
return;
}*/
int temperature = dht.readTemperature();
// xQueueSend( temHumiQueue , (int*) temperature,(TickType_t)0);
Serial.print("Humidity: ");Serial.print(humidity);Serial.print(" %\t");
Serial.print("Temperature: ");Serial.print(temperature);Serial.print(" *C ");
//vTaskResume( TaskHandle_menu );
vTaskDelay(1000/portTICK_PERIOD_MS);
}
}
void loop(){}