I work on a project which need some tasks carried out in the same time on
my Arduino Uno. And after few web researches, I found your project.
I try to make a simple example with a task which writes on the serial port.
But when I load the program, the arduino card sends me texts with strange
characters (example : GCÿ#ÿØ#ü¿cÿ¤äç¼ã£Dà [Ã'§'ä['¼¸C#$Dà)
Have you an idea where comes from this bug ?
This is my code :
/ Scheduler include files. /
/ serial interface include file. /
/ Create a handle for the serial port. /
static void vHelloWorld(void*);
static void vHelloWorld(void*)
for( ;; )
xSerialPrintf("Hello World !\n");
/ Main program loop /
int16_t main(void) attribute((OS_main));
xSerialPort = xSerialPortInitMinimal( 115200, portSERIAL_BUFFER,
avrSerialPrintf("Start of Main()\n");
xTaskCreate( vHelloWorld, ( signed portCHAR * ) "vHelloWorld", 50,
NULL,tskIDLE_PRIORITY+2, NULL );
thanks for writing.
Garbage on the serial port is almost always caused by a mismatch of speeds. The Arduino frequency of 16MHz is one of the worst cases, because it doesn't divide closely to any serial bit rate and there's always a small rate error.
I'm guessing that this case is caused because the CPU_CLOCK_HZ is not set to 16000000. This is done in the freeRTOS/include/FreeRTOSConfig.h file. Just adjust the comment appropriately, from my default below.
#define configCPU_CLOCK_HZ ( ( uint32_t ) 22118400 ) // Modded Arduino (usually 16000000) with 328p device
// #define configCPU_CLOCK_HZ ( ( uint32_t ) 16000000 ) // Arduino with 328p device
For a bit more background, see here.