Load the example code provided by Arduino FreeRTOS in File->Examples- >FreeRTOS-> Blink_AnalogRead. Questions: 1. Using

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Load the example code provided by Arduino FreeRTOS in File->Examples- >FreeRTOS-> Blink_AnalogRead. Questions: 1. Using

Post by answerhappygod »

Load The Example Code Provided By Arduino Freertos In File Examples Freertos Blink Analogread Questions 1 Using 1
Load The Example Code Provided By Arduino Freertos In File Examples Freertos Blink Analogread Questions 1 Using 1 (49.7 KiB) Viewed 37 times
Load The Example Code Provided By Arduino Freertos In File Examples Freertos Blink Analogread Questions 1 Using 2
Load The Example Code Provided By Arduino Freertos In File Examples Freertos Blink Analogread Questions 1 Using 2 (30.93 KiB) Viewed 37 times
Load The Example Code Provided By Arduino Freertos In File Examples Freertos Blink Analogread Questions 1 Using 3
Load The Example Code Provided By Arduino Freertos In File Examples Freertos Blink Analogread Questions 1 Using 3 (23.98 KiB) Viewed 37 times
Load the example code provided by Arduino FreeRTOS in File->Examples- >FreeRTOS-> Blink_AnalogRead. Questions: 1. Using a timer how long is the period? 2. If you change the delay time, what happens to the period of the blinking? Change the TaskBlink task as follows: . void TaskBlink (void *pvParameters) { (void) pvParameters; pinMode(LED_BUILTIN, OUTPUT); volatile int i = 0; for (;;) // A Task shall never return or exit. t digitalWrite(LED_BUILTIN, HIGH); for(i=0;i<30000;i++); digitalWrite(LED_BUILTIN, LOW); for(i=0;i<30000; i++); Questions: 1. Measure the period again. 2. What happens when you increase the loop to > 32,770? Set File - Preferences - Compiler warnings 'all' 3. This is modeling using CPU time what is the difference between this and vTaskDelay? Using the OS to multi-task You will have more than one task running and let the FreeRTOS scheduler manage the scheduling. Each task will run periodically, and each will use a certain amount of CPU time. Note tick" resolution is around 16ms) • Taski should run every about every 85ms and use about 30ms of CPU time (using CPU_work). • Task2 should run about every 30ms and use about 10ms of CPU time (again with
Blink_AnalogReads #include <Arduino_FreeRTOS.h> // define two tasks for Blink s AnalogRead void TaskBlinkt void *pvParameters); void TaskAnalogRead( void *pvParameters ): // the setup function runs once when you press reset or power the board void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); while (!Serial) :ll wait for serial port to connect. Needed for native USB, on LEONARDO, MICRO, YUN, and other 324 based boards. 1 // No set up two tasks to run independently, xTaskCreate TaskBlink "Blink // A name just for humans 129 // This stack size can be checked adjusted by reading the Stack Highwater NULL 2 // Priority, with 3 (configHAX_PRIORITIES - 1) being the highest, and being the lowest. NULL): . . + xTaskCreated TaskAnalogRead "AnalogRead 128 // Stack size NULL 1 // Priority + NULL) . . . // Now the task schedule, which takes over control of scheduling individual tasks, is automatically started. } void loop() // Empty. Things are done in Taaks.
void loop() // Empty. Things are done in Taska. i Tanke void Tas Blink(void *pvParameters) // This is a task. (void) pv parameters: // initialize digital LED_BUILTIN on pin 13 as an output. pinMode(LED_BUILTIN, OUTPUT): volatile in 1-0: for (2) I A Tak shall never return or exit. 1 digitalWrite(LED_BUILTIN, HIGH) // turn the LED on (HICH In the voltage level) VTaskDelay(1000 portTICK_PERIOD_MS): // wait for one second digitalWrite(LED_BUILTIN, LOW); // turn the LED oft by making the voltage LOW VratDelay(1000 / portTICK_PERIOD_MS): // wait for one second 1 > Void Tan AnalogRead(void parameters) // This 10 a tak. (void) p Parameters W zead the input on analog pin 01 int sensorValue AnalogRead(10): // print out the value you read: Serial.println(sensorValue) Vaskelay(1); // one tick delay 15m) in between reads for stability
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply