Browse Source

Version 1

unknown 6 months ago
commit
4be723a688
38 changed files with 385857 additions and 0 deletions
  1. BIN
      Analysis Of FreeRTOS on ESP32-Summary.pdf
  2. BIN
      Analysis of FreeRTOS on ESP32 S3.pdf
  3. 0 0
      README.md
  4. BIN
      Timing Analysis/10-millisecond-delay-tick-rate-100/10 millisecond time as task delay.kvdat
  5. BIN
      Timing Analysis/10-millisecond-delay-tick-rate-100/10 millisecond time as task delay.png
  6. BIN
      Timing Analysis/10-millisecond-delay-tick-rate-100/3 task 10 millisecond delay.png
  7. BIN
      Timing Analysis/10-millisecond-delay-tick-rate-100/3 task 10 millisecond time as task delay.kvdat
  8. BIN
      Timing Analysis/100-millisecond-delay-tick-rate-100/100 millisecond time as task delay.kvdat
  9. BIN
      Timing Analysis/100-millisecond-delay-tick-rate-100/100 millisecond time as task delay.png
  10. BIN
      Timing Analysis/1000 MHz Tick Rate/1.kvdat
  11. BIN
      Timing Analysis/1000 MHz Tick Rate/1.png
  12. BIN
      Timing Analysis/1000 MHz Tick Rate/2.kvdat
  13. BIN
      Timing Analysis/1000 MHz Tick Rate/2.png
  14. BIN
      Timing Analysis/1000 MHz Tick Rate/3.kvdat
  15. 58 0
      Timing Analysis/main.c
  16. BIN
      Timing Analysis/misc/0 millisecond as time delay.png
  17. BIN
      Timing Analysis/misc/0 millisecondtime as task delay.kvdat
  18. BIN
      Timing Analysis/misc/1 millisecond default config tick rate.png
  19. BIN
      Timing Analysis/misc/1 millisecond time as task delay.kvdat
  20. BIN
      Timing Analysis/misc/1 millisecond time as task delay.png
  21. BIN
      Timing Analysis/misc/1 milliseond task delay (defualt config) of tick rate hertz.kvdat
  22. BIN
      Timing Analysis/misc/deeper analysis of 1 millisecond delay.png
  23. BIN
      Timing Analysis/misc/portTICKPERIODMS_error.png
  24. BIN
      Timing Analysis/misc/simple blink- no-rtos.png
  25. BIN
      Timing Analysis/misc/tick-period-hz-10000.png
  26. BIN
      Timing Analysis/misc/time between to taks.png
  27. 8590 0
      behavior analysis/hw-interrupts/ISR-deferred.vcd
  28. 319851 0
      behavior analysis/hw-interrupts/hw-interrupt-behavior.vcd
  29. 122 0
      behavior analysis/hw-interrupts/interrupt-task-deferred.c
  30. 52712 0
      behavior analysis/queues/higher-priority-queue-preemption.vcd
  31. 109 0
      behavior analysis/queues/queues.c
  32. 510 0
      behavior analysis/queues/simple-queue-behavior.vcd
  33. 82 0
      behavior analysis/simple task/simple-task.c
  34. 2565 0
      behavior analysis/simple task/simple-task.vcd
  35. 84 0
      behavior analysis/software timers/software-timer-different-callback.c
  36. 707 0
      behavior analysis/software timers/software-timer-different-callback.vcd
  37. 66 0
      behavior analysis/software timers/software-timer-same-callback.c
  38. 401 0
      behavior analysis/software timers/software-timer-same-callback.vcd

BIN
Analysis Of FreeRTOS on ESP32-Summary.pdf


BIN
Analysis of FreeRTOS on ESP32 S3.pdf


+ 0 - 0
README.md


BIN
Timing Analysis/10-millisecond-delay-tick-rate-100/10 millisecond time as task delay.kvdat


BIN
Timing Analysis/10-millisecond-delay-tick-rate-100/10 millisecond time as task delay.png


BIN
Timing Analysis/10-millisecond-delay-tick-rate-100/3 task 10 millisecond delay.png


BIN
Timing Analysis/10-millisecond-delay-tick-rate-100/3 task 10 millisecond time as task delay.kvdat


BIN
Timing Analysis/100-millisecond-delay-tick-rate-100/100 millisecond time as task delay.kvdat


BIN
Timing Analysis/100-millisecond-delay-tick-rate-100/100 millisecond time as task delay.png


BIN
Timing Analysis/1000 MHz Tick Rate/1.kvdat


BIN
Timing Analysis/1000 MHz Tick Rate/1.png


BIN
Timing Analysis/1000 MHz Tick Rate/2.kvdat


BIN
Timing Analysis/1000 MHz Tick Rate/2.png


BIN
Timing Analysis/1000 MHz Tick Rate/3.kvdat


+ 58 - 0
Timing Analysis/main.c

@@ -0,0 +1,58 @@
+
+#include <stdio.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+
+#include "driver/gpio.h"
+#include "esp_log.h"
+
+#define GPIO1 14
+#define GPIO2 13
+#define GPIO3 12
+
+
+
+void blinky1(void *pvParameter)
+{
+    
+    gpio_set_direction(GPIO1,GPIO_MODE_OUTPUT);
+        
+    while(1) {    
+        gpio_set_level(GPIO1,1);
+        gpio_set_level(GPIO1,0);
+        ESP_LOGI("Task 1","From task 1");
+       vTaskDelay(pdMS_TO_TICKS(1));
+    }
+}
+
+
+void blinky2(void *pvParameter)
+{
+    gpio_set_direction(GPIO2,GPIO_MODE_OUTPUT);
+    while(1) {       
+        gpio_set_level(GPIO2,1);
+        gpio_set_level(GPIO2,0);
+        vTaskDelay(pdMS_TO_TICKS(1));
+    }
+}
+
+void blinky3(void *pvParameter)
+{
+    gpio_set_direction(GPIO3,GPIO_MODE_OUTPUT);
+    while(1) {
+        gpio_set_level(GPIO3,1);
+        gpio_set_level(GPIO3,0);
+        vTaskDelay(pdMS_TO_TICKS(1));
+    }
+}
+
+
+void app_main()
+{
+    ESP_LOGI("HEAP_MEMORY",ESP.getFreeHeap());
+    xTaskCreatePinnedToCore(&blinky1, "blinky 1", 3096,NULL,2,NULL,0 );
+    xTaskCreatePinnedToCore(&blinky2, "blinky 2", 3096,NULL,1,NULL,0 );
+    xTaskCreatePinnedToCore(&blinky3, "blinky 3", 3096,NULL,1,NULL,0 );
+}
+
+

BIN
Timing Analysis/misc/0 millisecond as time delay.png


BIN
Timing Analysis/misc/0 millisecondtime as task delay.kvdat


BIN
Timing Analysis/misc/1 millisecond default config tick rate.png


BIN
Timing Analysis/misc/1 millisecond time as task delay.kvdat


BIN
Timing Analysis/misc/1 millisecond time as task delay.png


BIN
Timing Analysis/misc/1 milliseond task delay (defualt config) of tick rate hertz.kvdat


BIN
Timing Analysis/misc/deeper analysis of 1 millisecond delay.png


BIN
Timing Analysis/misc/portTICKPERIODMS_error.png


BIN
Timing Analysis/misc/simple blink- no-rtos.png


BIN
Timing Analysis/misc/tick-period-hz-10000.png


BIN
Timing Analysis/misc/time between to taks.png


File diff suppressed because it is too large
+ 8590 - 0
behavior analysis/hw-interrupts/ISR-deferred.vcd


File diff suppressed because it is too large
+ 319851 - 0
behavior analysis/hw-interrupts/hw-interrupt-behavior.vcd


+ 122 - 0
behavior analysis/hw-interrupts/interrupt-task-deferred.c

@@ -0,0 +1,122 @@
+
+#include <stdio.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "driver/gpio.h"
+
+
+#define LED_RED GPIO_NUM_5
+#define LED_GREEN GPIO_NUM_2
+#define PushButton GPIO_NUM_14
+#define LED_BLUE GPIO_NUM_4 
+#define LED_YELLOW GPIO_NUM_22
+
+SemaphoreHandle_t binSem ;
+
+// hardware interrupt , 
+
+static void IRAM_ATTR intrHandlePushButton(void *args){
+  //vPrintString("inside interrupt service routine");
+  BaseType_t xHigherPriorityTaskWoken ;
+  xHigherPriorityTaskWoken = pdFALSE;
+
+  gpio_set_level(LED_GREEN,1);
+  xSemaphoreGiveFromISR(binSem , &xHigherPriorityTaskWoken);
+  if (xHigherPriorityTaskWoken){
+    gpio_set_level(LED_GREEN,0);
+     portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
+  }
+  else{
+  gpio_set_level(LED_GREEN,0);
+  }
+}
+
+static void IRAM_ATTR intrHandleLEDYELLOW(void *args){
+  //vPrintString("inside interrupt service routine");
+  
+  gpio_set_level(LED_YELLOW,1);
+  gpio_set_level(LED_YELLOW,0);
+  
+}
+
+
+
+void led_task_Red(void *pvParameter)
+{
+  while (1) {
+    gpio_set_level(LED_RED, 1);
+    gpio_set_level(LED_RED, 0);
+    printf("inside LED routine \n");
+    vTaskDelay(1);
+    
+ 
+}
+ vTaskDelete( NULL );
+}
+
+void led_task_Intr(void *pvParameter)
+{
+  while (1) {
+    xSemaphoreTake(binSem,portMAX_DELAY);
+    gpio_set_level(LED_BLUE, 1);
+    gpio_set_level(LED_BLUE, 0);
+    printf("inside ISR routine\n");
+    vTaskDelay(1);
+}
+ vTaskDelete( NULL );
+}
+
+
+extern "C" void app_main() {
+
+  //printf("\n%d",xPortGetCoreID());
+  
+  //setup GPIO to input and Output
+
+  gpio_set_direction(LED_RED, GPIO_MODE_OUTPUT);
+  gpio_set_direction(LED_GREEN,GPIO_MODE_OUTPUT);
+  gpio_set_direction(LED_BLUE,GPIO_MODE_OUTPUT);
+  gpio_set_direction(LED_YELLOW,GPIO_MODE_OUTPUT);
+  gpio_set_direction(PushButton , GPIO_MODE_INPUT);
+  gpio_set_level(PushButton,0);
+  gpio_set_level(LED_RED,0);
+  gpio_set_level(LED_GREEN,0);
+  gpio_set_level(LED_BLUE,0);
+  gpio_set_level(LED_YELLOW,0);
+  
+   
+   //attach GPIO to interrupt
+  gpio_set_intr_type(LED_RED,GPIO_INTR_POSEDGE);
+  gpio_install_isr_service(0);
+  gpio_isr_handler_add(LED_RED,intrHandlePushButton,NULL);
+  
+  gpio_set_intr_type(LED_GREEN,GPIO_INTR_POSEDGE);
+  gpio_install_isr_service(1);
+  gpio_isr_handler_add(LED_GREEN,intrHandleLEDYELLOW,NULL);
+  
+  
+  binSem =  xSemaphoreCreateBinary();
+  if (binSem != NULL){
+            
+      xTaskCreate(
+      &led_task_Red, // task function
+      "red_led_task", // task name
+      2048, // stack size in words
+      NULL, // pointer to parameters
+      1, // priority
+      NULL); // out pointer to task handle
+       xTaskCreate(
+      &led_task_Intr, // task function
+      "Intr_led_task", // task name
+      2048, // stack size in words
+      NULL, // pointer to parameters
+      3, // priority
+      NULL); // out pointer to task handle
+
+  }
+    
+
+  }
+
+  
+

File diff suppressed because it is too large
+ 52712 - 0
behavior analysis/queues/higher-priority-queue-preemption.vcd


+ 109 - 0
behavior analysis/queues/queues.c

@@ -0,0 +1,109 @@
+#include <stdio.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "driver/gpio.h"
+
+
+#define LED_RED GPIO_NUM_2
+#define LED_GREEN GPIO_NUM_4
+
+
+
+
+
+
+QueueHandle_t xQueue;
+
+
+
+
+
+
+void getQueueValue(void *pvParameter)
+{
+  int32_t value_to_recieve;
+  BaseType_t xStatusRecieve;
+  //const TickType_t xTicksToWait = pdMS_TO_TICKS( 50 );
+  gpio_num_t red_led = LED_RED ;
+  //uint8_t led_value = 0;
+  //gpio_reset_pin(red_led);
+  gpio_set_direction(red_led, GPIO_MODE_OUTPUT);
+
+
+
+
+  for(;;){
+    //led_value = 1;
+    gpio_set_level(red_led, 1);
+
+
+  xStatusRecieve = xQueueReceive(xQueue, &value_to_recieve, 0);
+  //printf("%d get value task \n",uxTaskGetStackHighWaterMark(NULL));
+  //if(xStatusRecieve != pdPASS){
+   // printf("cant get value \n");
+  //}
+  //else{
+  //printf("value recieved is %d \n",value_to_recieve);
+  //}
+  //led_value = 0;
+  gpio_set_level(red_led, 0);
+  vTaskDelay(pdMS_TO_TICKS(200));
+  }
+}
+
+
+void putQueueValue(void *pvParameters) {
+int32_t value_to_send = (int32_t ) pvParameters;
+//value_to_send = (int32_t) pvParameters ;
+BaseType_t xStatusSend;
+//TickType_t xTicksToWait = 1000;
+gpio_num_t green_led = LED_GREEN ;
+  //uint8_t led_value = 0;
+  //gpio_reset_pin(green_led);
+  gpio_set_direction(green_led, GPIO_MODE_OUTPUT);
+
+
+
+
+for(;;){
+
+
+
+
+gpio_set_level(green_led, 1);
+
+
+xStatusSend = xQueueSendToBack(xQueue,&value_to_send,0);
+
+
+
+
+  gpio_set_level(green_led, 0);
+  vTaskDelay(pdMS_TO_TICKS(1000));
+  }
+
+
+}
+
+
+
+
+extern "C" void app_main()
+//void app_main(void) //requires setup- and loop function
+{
+
+
+ 
+  xQueue = xQueueCreate(1,sizeof(int32_t));
+  if (xQueue != NULL){
+
+
+  xTaskCreate(putQueueValue,"Sender",2048,(void*)100 , 1,NULL);
+  xTaskCreate(getQueueValue,"Reciever",2048,NULL,1,NULL);
+ 
+ 
+  }
+  else{
+    printf("not enough space");
+  }
+}

+ 510 - 0
behavior analysis/queues/simple-queue-behavior.vcd

@@ -0,0 +1,510 @@
+$version Generated by Wokwi.com $end
+$date Sat, 29 Jul 2023 14:20:45 GMT $end
+$timescale 1ns $end
+$scope module logic $end
+$var wire 1 ! D2 $end
+$var wire 1 " D4 $end
+$upscope $end
+$enddefinitions $end
+#0
+0!
+#0
+0"
+#403950913
+1"
+#403961363
+0"
+#404164438
+1!
+#404167275
+0!
+#603856538
+1!
+#603866213
+0!
+#803856538
+1!
+#803866213
+0!
+#1003856550
+1!
+#1003866225
+0!
+#1203856538
+1!
+#1203866213
+0!
+#1403857425
+1"
+#1403868775
+0"
+#1403906838
+1!
+#1403909675
+0!
+#1603856538
+1!
+#1603866213
+0!
+#1803856538
+1!
+#1803866213
+0!
+#2003856538
+1!
+#2003866213
+0!
+#2203856538
+1!
+#2203866213
+0!
+#2403857425
+1"
+#2403868775
+0"
+#2403906838
+1!
+#2403909675
+0!
+#2603856538
+1!
+#2603866213
+0!
+#2803856538
+1!
+#2803866213
+0!
+#3003856538
+1!
+#3003866213
+0!
+#3203856538
+1!
+#3203866213
+0!
+#3403857425
+1"
+#3403868775
+0"
+#3403906838
+1!
+#3403909675
+0!
+#3603856538
+1!
+#3603866213
+0!
+#3803856538
+1!
+#3803866213
+0!
+#4003856538
+1!
+#4003866213
+0!
+#4203856550
+1!
+#4203866225
+0!
+#4403857425
+1"
+#4403868775
+0"
+#4403906838
+1!
+#4403909675
+0!
+#4603856538
+1!
+#4603866213
+0!
+#4803856538
+1!
+#4803866213
+0!
+#5003856538
+1!
+#5003866213
+0!
+#5203856538
+1!
+#5203866213
+0!
+#5403857425
+1"
+#5403868775
+0"
+#5403906838
+1!
+#5403909675
+0!
+#5603856538
+1!
+#5603866213
+0!
+#5803856538
+1!
+#5803866213
+0!
+#6003856538
+1!
+#6003866213
+0!
+#6203856538
+1!
+#6203866213
+0!
+#6403857425
+1"
+#6403868775
+0"
+#6403906838
+1!
+#6403909675
+0!
+#6603856538
+1!
+#6603866213
+0!
+#6803856538
+1!
+#6803866213
+0!
+#7003856538
+1!
+#7003866213
+0!
+#7203856538
+1!
+#7203866213
+0!
+#7403857425
+1"
+#7403868775
+0"
+#7403906838
+1!
+#7403909675
+0!
+#7603856538
+1!
+#7603866213
+0!
+#7803856538
+1!
+#7803866213
+0!
+#8003856538
+1!
+#8003866213
+0!
+#8203856538
+1!
+#8203866212
+0!
+#8403857425
+1"
+#8403868775
+0"
+#8403906837
+1!
+#8403909675
+0!
+#8603856538
+1!
+#8603866213
+0!
+#8803856538
+1!
+#8803866213
+0!
+#9003856538
+1!
+#9003866213
+0!
+#9203856538
+1!
+#9203866213
+0!
+#9403857425
+1"
+#9403868775
+0"
+#9403906838
+1!
+#9403909675
+0!
+#9603856538
+1!
+#9603866213
+0!
+#9803856538
+1!
+#9803866213
+0!
+#10003856538
+1!
+#10003866213
+0!
+#10203856538
+1!
+#10203866213
+0!
+#10403857425
+1"
+#10403868775
+0"
+#10403906838
+1!
+#10403909675
+0!
+#10603856538
+1!
+#10603866213
+0!
+#10803856538
+1!
+#10803866213
+0!
+#11003856538
+1!
+#11003866213
+0!
+#11203856538
+1!
+#11203866213
+0!
+#11403857425
+1"
+#11403868775
+0"
+#11403906838
+1!
+#11403909675
+0!
+#11603856538
+1!
+#11603866213
+0!
+#11803856538
+1!
+#11803866213
+0!
+#12003856538
+1!
+#12003866213
+0!
+#12203856538
+1!
+#12203866213
+0!
+#12403857425
+1"
+#12403868775
+0"
+#12403906838
+1!
+#12403909675
+0!
+#12603856538
+1!
+#12603866213
+0!
+#12803856538
+1!
+#12803866213
+0!
+#13003856538
+1!
+#13003866213
+0!
+#13203856538
+1!
+#13203866213
+0!
+#13403857425
+1"
+#13403868775
+0"
+#13403906838
+1!
+#13403909675
+0!
+#13603856538
+1!
+#13603866213
+0!
+#13803856538
+1!
+#13803866213
+0!
+#14003856538
+1!
+#14003866213
+0!
+#14203856538
+1!
+#14203866213
+0!
+#14403857425
+1"
+#14403868775
+0"
+#14403906838
+1!
+#14403909675
+0!
+#14603856538
+1!
+#14603866213
+0!
+#14803856538
+1!
+#14803866213
+0!
+#15003856538
+1!
+#15003866213
+0!
+#15203856538
+1!
+#15203866213
+0!
+#15403857425
+1"
+#15403868775
+0"
+#15403906838
+1!
+#15403909675
+0!
+#15603856538
+1!
+#15603866213
+0!
+#15803856538
+1!
+#15803866213
+0!
+#16003856537
+1!
+#16003866213
+0!
+#16203856550
+1!
+#16203866225
+0!
+#16403857438
+1"
+#16403868787
+0"
+#16403906850
+1!
+#16403909688
+0!
+#16603856550
+1!
+#16603866225
+0!
+#16803856538
+1!
+#16803866213
+0!
+#17003856537
+1!
+#17003866213
+0!
+#17203856538
+1!
+#17203866213
+0!
+#17403857425
+1"
+#17403868775
+0"
+#17403906838
+1!
+#17403909675
+0!
+#17603856538
+1!
+#17603866213
+0!
+#17803856538
+1!
+#17803866213
+0!
+#18003856538
+1!
+#18003866213
+0!
+#18203856538
+1!
+#18203866213
+0!
+#18403857425
+1"
+#18403868775
+0"
+#18403906838
+1!
+#18403909675
+0!
+#18603856538
+1!
+#18603866213
+0!
+#18803856538
+1!
+#18803866213
+0!
+#19003856538
+1!
+#19003866213
+0!
+#19203856538
+1!
+#19203866213
+0!
+#19403857425
+1"
+#19403868775
+0"
+#19403906838
+1!
+#19403909675
+0!
+#19603856538
+1!
+#19603866213
+0!
+#19803856538
+1!
+#19803866213
+0!
+#20003856538
+1!
+#20003866213
+0!
+#20203856538
+1!
+#20203866213
+0!
+#20403857425
+1"
+#20403868775
+0"
+#20403906838
+1!
+#20403909675
+0!
+#20603856538
+1!
+#20603866213
+0!
+#20803856538
+1!
+#20803866213
+0!
+#20877613075
+0#

+ 82 - 0
behavior analysis/simple task/simple-task.c

@@ -0,0 +1,82 @@
+
+
+#include <stdio.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "driver/gpio.h"
+
+
+#define LED_RED GPIO_NUM_2
+#define LED_GREEN GPIO_NUM_4
+#define LED_BLUE GPIO_NUM_5
+
+
+struct led_task_parameters_t
+{
+  gpio_num_t led_gpio;
+  TickType_t blink_time;
+  char led_name[10];
+};
+
+
+static led_task_parameters_t red_led_gpio = {LED_RED, 2000,"Red"};
+static led_task_parameters_t blue_led_gpio = {LED_BLUE, 2000,"Blue"};
+static led_task_parameters_t green_led_gpio = {LED_GREEN, 2000,"Green"};
+
+
+
+
+void led_task(void *pvParameter)
+{
+  gpio_num_t led_gpio = ((led_task_parameters_t *)pvParameter)-> led_gpio;
+  TickType_t blink_time = ((led_task_parameters_t *)pvParameter)-> blink_time;
+  char *led_name = ((led_task_parameters_t *)pvParameter)-> led_name;
+  uint8_t led_value = 0;
+  gpio_reset_pin(led_gpio);
+  gpio_set_direction(led_gpio, GPIO_MODE_OUTPUT);
+
+
+
+
+  while (1) {
+    gpio_set_level(led_gpio, led_value);
+    led_value = !led_value;
+    //printf("%s \n",led_name);
+    //printf("%d \n",(xPortGetFreeHeapSize()));
+    printf("%d in %s \n",(uxTaskGetStackHighWaterMark(NULL)),led_name);
+    vTaskDelay(blink_time / portTICK_PERIOD_MS);
+  }
+  vTaskDelete( NULL );
+}
+
+
+
+
+extern "C" void app_main()
+{
+  xTaskCreate(
+    &led_task, // task function
+    "red_led_task", // task name
+    2048, // stack size in words
+    &red_led_gpio, // pointer to parameters
+    5, // priority
+    NULL); // out pointer to task handle
+
+
+  xTaskCreate(
+    &led_task, // task function
+    "blue_led_task", // task name
+    2048, // stack size in words
+    &blue_led_gpio, // pointer to parameters
+    5, // priority
+    NULL); // out pointer to task handle
+
+
+  xTaskCreate(
+    &led_task, // task function
+    "green_led_task", // task name
+    2048, // stack size in words
+    &green_led_gpio, // pointer to parameters
+    5, // priority
+    NULL); // out pointer to task handle
+}

File diff suppressed because it is too large
+ 2565 - 0
behavior analysis/simple task/simple-task.vcd


+ 84 - 0
behavior analysis/software timers/software-timer-different-callback.c

@@ -0,0 +1,84 @@
+#include <stdio.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "driver/gpio.h"
+
+
+#define LED_RED GPIO_NUM_5
+#define LED_GREEN GPIO_NUM_2
+#define LED_BLUE GPIO_NUM_4
+
+
+
+
+static TimerHandle_t led1 , led2 ,led3= NULL ;  
+
+
+
+
+void TimerLedControlRed(TimerHandle_t xtimer){
+ // uint32_t led_timer_id = (uint32_t) pvTimerGetTimerID(xtimer) ;
+  //red led
+
+
+  gpio_set_level(LED_RED,!gpio_get_level(LED_RED));
+ printf(" from RED %d\n",ESP.getFreeHeap());
+
+
+
+
+  //printf("inside timer\n");
+}
+void TimerLedControlGreen(TimerHandle_t xtimer){
+ // uint32_t led_timer_id = (uint32_t) pvTimerGetTimerID(xtimer) ;
+  gpio_set_level(LED_GREEN,!gpio_get_level(LED_GREEN));
+  printf(" from GREEN %d\n",ESP.getFreeHeap());
+
+
+  //printf("inside timer\n");
+}
+
+
+void TimerLedControlBlue(TimerHandle_t xtimer){
+ // uint32_t led_timer_id = (uint32_t) pvTimerGetTimerID(xtimer) ;
+  //red led
+  gpio_set_level(LED_BLUE,!gpio_get_level(LED_BLUE));
+printf(" from BLUE %d\n",ESP.getFreeHeap());
+
+
+
+
+  //printf("inside timer\n");
+}
+
+
+extern "C" void app_main()
+{
+
+
+
+
+  //setting GPIO Direction (INPUT , OUTPUT)
+ printf(" from main 1 %d\n",ESP.getFreeHeap());
+
+
+  gpio_set_direction(LED_RED, GPIO_MODE_OUTPUT);
+  gpio_set_direction(LED_GREEN, GPIO_MODE_OUTPUT);
+  gpio_set_direction(LED_BLUE, GPIO_MODE_OUTPUT);
+ 
+  //timer tasks
+ printf(" from main 2 %d\n",ESP.getFreeHeap());
+
+
+  led1 = xTimerCreate("LED Red", pdMS_TO_TICKS(100),pdTRUE,(void *) 0,TimerLedControlRed);
+  led2 = xTimerCreate("LED Green", pdMS_TO_TICKS(100),pdTRUE,(void *) 1,TimerLedControlGreen);
+  led3 = xTimerCreate("LED Blue", pdMS_TO_TICKS(100),pdTRUE,(void *) 2,TimerLedControlBlue);
+  xTimerStart(led1,0);
+  xTimerStart(led2,0);
+  xTimerStart(led3,0);
+ printf(" from main 3 %d\n",ESP.getFreeHeap());
+
+
+
+
+}

+ 707 - 0
behavior analysis/software timers/software-timer-different-callback.vcd

@@ -0,0 +1,707 @@
+$version Generated by Wokwi.com $end
+$date Sat, 05 Aug 2023 15:21:26 GMT $end
+$timescale 1ns $end
+$scope module logic $end
+$var wire 1 ! D0 $end
+$var wire 1 " D1 $end
+$var wire 1 # D2 $end
+$upscope $end
+$enddefinitions $end
+#0
+0!
+#0
+0"
+#0
+0#
+#507105388
+1!
+#507131238
+1"
+#507140212
+1#
+#607105388
+0!
+#607131488
+0"
+#607140600
+0#
+#707105388
+1!
+#707131238
+1"
+#707140213
+1#
+#807105388
+0!
+#807131488
+0"
+#807140600
+0#
+#907105388
+1!
+#907131238
+1"
+#907140213
+1#
+#1007105400
+0!
+#1007131500
+0"
+#1007140613
+0#
+#1107105388
+1!
+#1107131238
+1"
+#1107140213
+1#
+#1207105388
+0!
+#1207131488
+0"
+#1207140600
+0#
+#1307105388
+1!
+#1307131238
+1"
+#1307140213
+1#
+#1407105388
+0!
+#1407131488
+0"
+#1407140600
+0#
+#1507105388
+1!
+#1507131238
+1"
+#1507140213
+1#
+#1607105388
+0!
+#1607131488
+0"
+#1607140600
+0#
+#1707105388
+1!
+#1707131238
+1"
+#1707140213
+1#
+#1807105388
+0!
+#1807131488
+0"
+#1807140600
+0#
+#1907105388
+1!
+#1907131238
+1"
+#1907140213
+1#
+#2007105387
+0!
+#2007131488
+0"
+#2007140600
+0#
+#2107105387
+1!
+#2107131238
+1"
+#2107140213
+1#
+#2207105388
+0!
+#2207131488
+0"
+#2207140600
+0#
+#2307105388
+1!
+#2307131238
+1"
+#2307140213
+1#
+#2407105388
+0!
+#2407131488
+0"
+#2407140600
+0#
+#2507105388
+1!
+#2507131238
+1"
+#2507140213
+1#
+#2607105388
+0!
+#2607131488
+0"
+#2607140600
+0#
+#2707105388
+1!
+#2707131238
+1"
+#2707140213
+1#
+#2807105388
+0!
+#2807131488
+0"
+#2807140600
+0#
+#2907105388
+1!
+#2907131238
+1"
+#2907140213
+1#
+#3007105388
+0!
+#3007131488
+0"
+#3007140600
+0#
+#3107105388
+1!
+#3107131238
+1"
+#3107140213
+1#
+#3207105388
+0!
+#3207131488
+0"
+#3207140600
+0#
+#3307105388
+1!
+#3307131238
+1"
+#3307140213
+1#
+#3407105388
+0!
+#3407131488
+0"
+#3407140600
+0#
+#3507105388
+1!
+#3507131238
+1"
+#3507140213
+1#
+#3607105388
+0!
+#3607131488
+0"
+#3607140600
+0#
+#3707105388
+1!
+#3707131238
+1"
+#3707140213
+1#
+#3807105388
+0!
+#3807131488
+0"
+#3807140600
+0#
+#3907105388
+1!
+#3907131238
+1"
+#3907140213
+1#
+#4007105400
+0!
+#4007131500
+0"
+#4007140612
+0#
+#4107105388
+1!
+#4107131238
+1"
+#4107140213
+1#
+#4207105400
+0!
+#4207131500
+0"
+#4207140613
+0#
+#4307105388
+1!
+#4307131238
+1"
+#4307140213
+1#
+#4407105388
+0!
+#4407131488
+0"
+#4407140600
+0#
+#4507105388
+1!
+#4507131238
+1"
+#4507140213
+1#
+#4607105388
+0!
+#4607131488
+0"
+#4607140600
+0#
+#4707105388
+1!
+#4707131238
+1"
+#4707140213
+1#
+#4807105388
+0!
+#4807131488
+0"
+#4807140600
+0#
+#4907105388
+1!
+#4907131238
+1"
+#4907140213
+1#
+#5007105388
+0!
+#5007131488
+0"
+#5007140600
+0#
+#5107105388
+1!
+#5107131238
+1"
+#5107140213
+1#
+#5207105388
+0!
+#5207131488
+0"
+#5207140600
+0#
+#5307105388
+1!
+#5307131238
+1"
+#5307140213
+1#
+#5407105388
+0!
+#5407131488
+0"
+#5407140600
+0#
+#5507105388
+1!
+#5507131238
+1"
+#5507140213
+1#
+#5607105388
+0!
+#5607131488
+0"
+#5607140600
+0#
+#5707105388
+1!
+#5707131238
+1"
+#5707140213
+1#
+#5807105388
+0!
+#5807131488
+0"
+#5807140600
+0#
+#5907105388
+1!
+#5907131238
+1"
+#5907140213
+1#
+#6007105388
+0!
+#6007131488
+0"
+#6007140600
+0#
+#6107105388
+1!
+#6107131238
+1"
+#6107140213
+1#
+#6207105388
+0!
+#6207131488
+0"
+#6207140600
+0#
+#6307105388
+1!
+#6307131238
+1"
+#6307140213
+1#
+#6407105388
+0!
+#6407131488
+0"
+#6407140600
+0#
+#6507105388
+1!
+#6507131238
+1"
+#6507140213
+1#
+#6607105388
+0!
+#6607131488
+0"
+#6607140600
+0#
+#6707105388
+1!
+#6707131238
+1"
+#6707140213
+1#
+#6807105388
+0!
+#6807131488
+0"
+#6807140600
+0#
+#6907105388
+1!
+#6907131238
+1"
+#6907140213
+1#
+#7007105388
+0!
+#7007131488
+0"
+#7007140600
+0#
+#7107105388
+1!
+#7107131238
+1"
+#7107140213
+1#
+#7207105388
+0!
+#7207131488
+0"
+#7207140600
+0#
+#7307105388
+1!
+#7307131238
+1"
+#7307140213
+1#
+#7407105388
+0!
+#7407131488
+0"
+#7407140600
+0#
+#7507105388
+1!
+#7507131238
+1"
+#7507140213
+1#
+#7607105388
+0!
+#7607131488
+0"
+#7607140600
+0#
+#7707105388
+1!
+#7707131238
+1"
+#7707140213
+1#
+#7807105388
+0!
+#7807131488
+0"
+#7807140600
+0#
+#7907105388
+1!
+#7907131238
+1"
+#7907140213
+1#
+#8007105387
+0!
+#8007131488
+0"
+#8007140600
+0#
+#8107105400
+1!
+#8107131250
+1"
+#8107140225
+1#
+#8207105388
+0!
+#8207131488
+0"
+#8207140600
+0#
+#8307105388
+1!
+#8307131238
+1"
+#8307140213
+1#
+#8407105388
+0!
+#8407131487
+0"
+#8407140600
+0#
+#8507105387
+1!
+#8507131237
+1"
+#8507140212
+1#
+#8607105388
+0!
+#8607131488
+0"
+#8607140600
+0#
+#8707105388
+1!
+#8707131238
+1"
+#8707140213
+1#
+#8807105388
+0!
+#8807131488
+0"
+#8807140600
+0#
+#8907105388
+1!
+#8907131238
+1"
+#8907140213
+1#
+#9007105388
+0!
+#9007131488
+0"
+#9007140600
+0#
+#9107105388
+1!
+#9107131238
+1"
+#9107140213
+1#
+#9207105388
+0!
+#9207131488
+0"
+#9207140600
+0#
+#9307105388
+1!
+#9307131238
+1"
+#9307140213
+1#
+#9407105388
+0!
+#9407131488
+0"
+#9407140600
+0#
+#9507105388
+1!
+#9507131238
+1"
+#9507140213
+1#
+#9607105388
+0!
+#9607131488
+0"
+#9607140600
+0#
+#9707105388
+1!
+#9707131238
+1"
+#9707140213
+1#
+#9807105388
+0!
+#9807131488
+0"
+#9807140600
+0#
+#9907105388
+1!
+#9907131238
+1"
+#9907140213
+1#
+#10007105388
+0!
+#10007131488
+0"
+#10007140600
+0#
+#10107105388
+1!
+#10107131238
+1"
+#10107140213
+1#
+#10207105388
+0!
+#10207131488
+0"
+#10207140600
+0#
+#10307105388
+1!
+#10307131238
+1"
+#10307140213
+1#
+#10407105388
+0!
+#10407131488
+0"
+#10407140600
+0#
+#10507105388
+1!
+#10507131238
+1"
+#10507140213
+1#
+#10607105388
+0!
+#10607131488
+0"
+#10607140600
+0#
+#10707105388
+1!
+#10707131238
+1"
+#10707140213
+1#
+#10807105388
+0!
+#10807131488
+0"
+#10807140600
+0#
+#10907105388
+1!
+#10907131238
+1"
+#10907140213
+1#
+#11007105388
+0!
+#11007131488
+0"
+#11007140600
+0#
+#11107105388
+1!
+#11107131238
+1"
+#11107140213
+1#
+#11207105388
+0!
+#11207131488
+0"
+#11207140600
+0#
+#11307105388
+1!
+#11307131238
+1"
+#11307140213
+1#
+#11407105388
+0!
+#11407131488
+0"
+#11407140600
+0#
+#11507105388
+1!
+#11507131238
+1"
+#11507140213
+1#
+#11607105388
+0!
+#11607131488
+0"
+#11607140600
+0#
+#11707105388
+1!
+#11707131238
+1"
+#11707140213
+1#
+#11807105388
+0!
+#11807131488
+0"
+#11807140600
+0#
+#11907105388
+1!
+#11907131238
+1"
+#11907140213
+1#
+#11915539038
+1!

+ 66 - 0
behavior analysis/software timers/software-timer-same-callback.c

@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "driver/gpio.h"
+
+
+#define LED_RED GPIO_NUM_5
+#define LED_GREEN GPIO_NUM_2
+#define LED_BLUE GPIO_NUM_4
+
+
+
+
+static TimerHandle_t led1 , led2 ,led3= NULL ;  
+
+
+
+
+
+
+
+
+
+
+void TimerLedControl(TimerHandle_t xtimer){
+  uint32_t led_timer_id = (uint32_t) pvTimerGetTimerID(xtimer) ;
+  //red led
+  if (led_timer_id == 0){
+  gpio_set_level(LED_RED,!gpio_get_level(LED_RED));
+  }
+  //green led
+  if (led_timer_id == 1){
+  gpio_set_level(LED_GREEN,!gpio_get_level(LED_GREEN));
+  }
+  //blue led
+  if (led_timer_id == 2){
+  gpio_set_level(LED_BLUE,!gpio_get_level(LED_BLUE));
+  }
+  printf("inside timer\n");
+
+
+}
+
+
+extern "C" void app_main()
+{
+
+
+
+
+  //setting GPIO Direction (INPUT , OUTPUT)
+
+
+  gpio_set_direction(LED_RED, GPIO_MODE_OUTPUT);
+  gpio_set_direction(LED_GREEN, GPIO_MODE_OUTPUT);
+  gpio_set_direction(LED_BLUE, GPIO_MODE_OUTPUT);
+ 
+  //timer tasks
+
+
+  led1 = xTimerCreate("LED Red", pdMS_TO_TICKS(100),pdTRUE,(void *) 0,TimerLedControl);
+  led2 = xTimerCreate("LED Green", pdMS_TO_TICKS(100),pdTRUE,(void *) 1,TimerLedControl);
+  led3 = xTimerCreate("LED Blue", pdMS_TO_TICKS(100),pdTRUE,(void *) 2,TimerLedControl);
+  xTimerStart(led1,0);
+  xTimerStart(led2,0);
+  xTimerStart(led3,0);

+ 401 - 0
behavior analysis/software timers/software-timer-same-callback.vcd

@@ -0,0 +1,401 @@
+$version Generated by Wokwi.com $end
+$date Sat, 05 Aug 2023 13:31:53 GMT $end
+$timescale 1ns $end
+$scope module logic $end
+$var wire 1 ! D0 $end
+$var wire 1 " D1 $end
+$var wire 1 # D2 $end
+$upscope $end
+$enddefinitions $end
+#0
+0!
+#0
+0"
+#0
+0#
+#507211825
+1!
+#507436325
+1"
+#507709300
+1#
+#607211825
+0!
+#607413700
+0"
+#607686925
+0#
+#707211825
+1!
+#707413450
+1"
+#707686425
+1#
+#807211825
+0!
+#807413700
+0"
+#807686925
+0#
+#907211825
+1!
+#907413450
+1"
+#907686425
+1#
+#1007211825
+0!
+#1007413700
+0"
+#1007686925
+0#
+#1107211825
+1!
+#1107413450
+1"
+#1107686425
+1#
+#1207211825
+0!
+#1207413700
+0"
+#1207686925
+0#
+#1307211825
+1!
+#1307413450
+1"
+#1307686425
+1#
+#1407211825
+0!
+#1407413700
+0"
+#1407686925
+0#
+#1507211825
+1!
+#1507413450
+1"
+#1507686425
+1#
+#1607211825
+0!
+#1607413700
+0"
+#1607686925
+0#
+#1707211825
+1!
+#1707413450
+1"
+#1707686425
+1#
+#1807211825
+0!
+#1807413700
+0"
+#1807686925
+0#
+#1907211825
+1!
+#1907413450
+1"
+#1907686425
+1#
+#2007211837
+0!
+#2007413713
+0"
+#2007686938
+0#
+#2107211825
+1!
+#2107413450
+1"
+#2107686425
+1#
+#2207211825
+0!
+#2207413700
+0"
+#2207686925
+0#
+#2307211825
+1!
+#2307413450
+1"
+#2307686425
+1#
+#2407211825
+0!
+#2407413700
+0"
+#2407686925
+0#
+#2507211825
+1!
+#2507413450
+1"
+#2507686425
+1#
+#2607211825
+0!
+#2607413700
+0"
+#2607686925
+0#
+#2707211825
+1!
+#2707413450
+1"
+#2707686425
+1#
+#2807211825
+0!
+#2807413700
+0"
+#2807686925
+0#
+#2907211825
+1!
+#2907413450
+1"
+#2907686425
+1#
+#3007211825
+0!
+#3007413700
+0"
+#3007686925
+0#
+#3107211825
+1!
+#3107413450
+1"
+#3107686425
+1#
+#3207211825
+0!
+#3207413700
+0"
+#3207686925
+0#
+#3307211825
+1!
+#3307413450
+1"
+#3307686425
+1#
+#3407211825
+0!
+#3407413700
+0"
+#3407686925
+0#
+#3507211825
+1!
+#3507413450
+1"
+#3507686425
+1#
+#3607211825
+0!
+#3607413700
+0"
+#3607686925
+0#
+#3707211825
+1!
+#3707413450
+1"
+#3707686425
+1#
+#3807211825
+0!
+#3807413700
+0"
+#3807686925
+0#
+#3907211825
+1!
+#3907413450
+1"
+#3907686425
+1#
+#4007211825
+0!
+#4007413700
+0"
+#4007686925
+0#
+#4107211825
+1!
+#4107413450
+1"
+#4107686425
+1#
+#4207211838
+0!
+#4207413713
+0"
+#4207686938
+0#
+#4307211825
+1!
+#4307413450
+1"
+#4307686425
+1#
+#4407211825
+0!
+#4407413700
+0"
+#4407686925
+0#
+#4507211825
+1!
+#4507413450
+1"
+#4507686425
+1#
+#4607211825
+0!
+#4607413700
+0"
+#4607686925
+0#
+#4707211825
+1!
+#4707413450
+1"
+#4707686425
+1#
+#4807211825
+0!
+#4807413700
+0"
+#4807686925
+0#
+#4907211825
+1!
+#4907413450
+1"
+#4907686425
+1#
+#5007211825
+0!
+#5007413700
+0"
+#5007686925
+0#
+#5107211825
+1!
+#5107413450
+1"
+#5107686425
+1#
+#5207211825
+0!
+#5207413700
+0"
+#5207686925
+0#
+#5307211825
+1!
+#5307413450
+1"
+#5307686425
+1#
+#5407211825
+0!
+#5407413700
+0"
+#5407686925
+0#
+#5507211825
+1!
+#5507413450
+1"
+#5507686425
+1#
+#5607211825
+0!
+#5607413700
+0"
+#5607686925
+0#
+#5707211825
+1!
+#5707413450
+1"
+#5707686425
+1#
+#5807211825
+0!
+#5807413700
+0"
+#5807686925
+0#
+#5907211825
+1!
+#5907413450
+1"
+#5907686425
+1#
+#6007211825
+0!
+#6007413700
+0"
+#6007686925
+0#
+#6107211825
+1!
+#6107413450
+1"
+#6107686425
+1#
+#6207211825
+0!
+#6207413700
+0"
+#6207686925
+0#
+#6307211825
+1!
+#6307413450
+1"
+#6307686425
+1#
+#6407211825
+0!
+#6407413700
+0"
+#6407686925
+0#
+#6507211825
+1!
+#6507413450
+1"
+#6507686425
+1#
+#6607211825
+0!
+#6607413700
+0"
+#6607686925
+0#
+#6707211825
+1!
+#6707413450
+1"
+#6707686425
+1#
+#6807211825
+0!
+#6807413700
+0"
+#6807686925
+0#
+#6866612300
+0!