I have tried different bootloaders with no luck. FreeRTOS does not work on 5 new Nano boards but it works on one I bought 6+ years ago.
Any suggestions?
Thanks Kurt
I have tried different bootloaders with no luck. FreeRTOS does not work on 5 new Nano boards but it works on one I bought 6+ years ago.
Any suggestions?
Thanks Kurt
Check very carefully - do your new Nanos have the ATMEGA328PB chip? A picture might help us help you.
Does not work, how, exactly?
Have you tried simple example from IDE?
Post a sketch to blink two leds concurrently at different rates using Arduino_FreeRTOS.h library and your Arduino NANO.
I run one of the FreeRTOS examples using ArduinoIDE and nothing happens. The old one works. It also works on the UNO I have.
Very strange.
#include <Arduino_FreeRTOS.h>
void TaskBlink(void *pvParameters);
void TaskSerial(void *pvParameters);
void setup() {
xTaskCreate(TaskBlink, "LED Blink", 256, NULL, 2, NULL);
xTaskCreate(TaskSerial, "Serial Print", 256, NULL, 1, NULL);
}
void loop() {
// Not used when FreeRTOS is running
}
void TaskBlink(void *pvParameters) {
pinMode(LED_BUILTIN, OUTPUT);
while (1) {
digitalWrite(LED_BUILTIN, HIGH);
vTaskDelay(500 / portTICK_PERIOD_MS);
digitalWrite(LED_BUILTIN, LOW);
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}
void TaskSerial(void *pvParameters) {
Serial.begin(9600);
vTaskDelay(500 / portTICK_PERIOD_MS);
while (1) {
Serial.println("FreeRTOS");
vTaskDelay(700 / portTICK_PERIOD_MS);
}
}
Thanks Kurt
It's a whole lot easier reading code when you enclose it in a code block with the <CODE/> tool.
#include <Arduino_FreeRTOS.h>
void TaskBlink(void *pvParameters);
void TaskSerial(void *pvParameters);
void setup() {
xTaskCreate(TaskBlink, "LED Blink", 256, NULL, 2, NULL);
xTaskCreate(TaskSerial, "Serial Print", 256, NULL, 1, NULL);
}
void loop() {
// Not used when FreeRTOS is running
}
void TaskBlink(void *pvParameters) {
pinMode(LED_BUILTIN, OUTPUT);
while( 1 ) {
digitalWrite(LED_BUILTIN, HIGH);
vTaskDelay(500 / portTICK_PERIOD_MS);
digitalWrite(LED_BUILTIN, LOW);
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}
void TaskSerial(void *pvParameters) {
Serial.begin(115200);
vTaskDelay(500 / portTICK_PERIOD_MS);
while( 1 ) {
Serial.println("FreeRTOS");
vTaskDelay(700 / portTICK_PERIOD_MS);
}
}
All I can say is that it worked for me when I uploaded it on a reasonably new Nano.
Sorry about the code block thing. This is my first time here.
Good time to read the pinned post re 'How to get the most from the forum'.
Why not? If I wish, I can place code in the loop() function to blink an external led at DPin-2.
loop() is hooked to the idle task. So code in loop() will run whenever there is no other code that's ready to run.
Do simple sketches work on the "bad" Nano ? The classis Blink sketch for example but maybe change the timings to ensure that it is really a newly installed sketch that is being used.
Have you enabled verbose output during upload via the IDE preferences options ?
Do you mean that you have tried both the "old" and the "new" bootloader from the IDE selection menu or do you mean that you have installed a different bootloader on the Nano ? If it is the latter then say how you did this because it is possible to either have fuse setting which do not match the bootloader or it is also possible to erase the freshly installed bootloader if a programmer is installed on the ICSP header when the first test sketch is uploaded.
Yes simple sketches work.
I tried loading an old bootloader from the IDE (using an UNO) but it didn't make a difference.
Can you confirm that the blink example works?
If it does, then you know it's not a problem with the built in LED.
Perhaps add Serial.begin(115200) and some Serial.println()s in setup() to see whether the code runs at all.
I tried this. Nothing prints.
After loading with "9716 bytes of flash verified" the only thing that happens is the onboard LED flashes 2 seconds on 2 seconds off. I tried changing the delays and the blinking is the same.
Now I am getting FLASH errors. I may be wrong but I think these chips are counterfeit.
Kurt
#include <Arduino_FreeRTOS.h>
//void TaskBlink(void *pvParameters);
//void TaskSerial(void *pvParameters);
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
delay(1000);
for (int i = 0; i <= 30; i++) {
Serial.print("Test before-");
Serial.println(i);
delay(500);
}
//xTaskCreate(TaskBlink, "LED Blink",128, NULL, 1, NULL);
//xTaskCreate(TaskSerial, "Serial Print", 128, NULL, 1, NULL);
}
void loop() {
// Not used when FreeRTOS is running
}
void TaskBlink(void *pvParameters) {
while (1) {
digitalWrite(LED_BUILTIN, HIGH);
vTaskDelay(800 / portTICK_PERIOD_MS);
digitalWrite(LED_BUILTIN, LOW);
vTaskDelay(100 / portTICK_PERIOD_MS);
}
}
void TaskSerial(void *pvParameters) {
while(1){
Serial.println("Test in task");
vTaskDelay(100 / portTICK_PERIOD_MS);
}
}
I forgot to says yes simple sketches work all the time, Blink etc
If you get such errors, then post these. Ensure that you show us the verbose output.
You can "convert" a Nano to a Uno simply by declaring the target Nano as a Uno when installing the bootloader. You then free an extra 1.5k of flash memory. With all future operations on such a converted Nano, you declare it to the IDE as a Uno.
This is interesting
If I include "Arduino_FreeRTOS.h" this doesn't run at all. If I comment it out it runs fine.
Note: with include out there are no Flash errors , in I get them sometimes.
//#include <Arduino_FreeRTOS.h>
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
delay(1000);
for (int i = 0; i <= 10; i++) {
Serial.print("Test before-");
Serial.println(i);
delay(500);
}
}
void loop() {
for (int i = 0; i <= 30; i++) {
Serial.print("Test in loop-");
Serial.println(i);
delay(500);
}
}
That could be, but it might not be the show stopper. I looked through my Nanos and found one where the G in MEGA matched yours, with both a horizontal and vertical line in the lower right, rather than just the horizontal line that was on most of the rest. Running a counterfeit 328P test, it indicated that that one was indeed a "free enterprise" one. So I loaded your FreeRTOS test into that one... and it still worked.
RE counterfeit test , interesting
Here is a Flash failure dump
vrdude version 8.0-arduino.1
Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is C:\Users\Kurt\AppData\Local\Arduino15\packages\arduino\tools\avrdude\8.0.0-arduino1\etc\avrdude.conf
Using port : COM5
Using programmer : arduino
Setting baud rate : 115200
AVR part : ATmega328P
Programming modes : SPM, ISP, HVPP, debugWIRE
Programmer type : Arduino
Description : Arduino bootloader using STK500 v1 protocol
HW Version : 3
FW Version : 4.4
AVR device initialized and ready to accept instructions
Device signature = 1E 95 0F (ATmega328P, ATA6614Q, LGT8F328P)
Reading 9914 bytes for flash from input file Simple_print.ino.hex
in 1 section [0, 0x26b9]: 78 pages and 70 pad bytes
Writing 9914 bytes to flash
Writing | ################################################## | 100% 1.44s
Reading | ################################################## | 100% 1.19s
Warning: flash verification mismatch
device 0xc0 != input 0xa6 at addr 0x17ae (error)
device 0xd7 != input 0x99 at addr 0x262e (error)
Error: flash verification mismatch
Avrdude done. Thank you.
Failed uploading: uploading error: exit status 1