// FreeRTOS includes
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
// STM32 Library includes
#include "stm32f10x_usart.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_gpio.h"
void configureUSART2();
void writebytesTask(void *params);
int main(void)
{
configureUSART2();
xTaskCreate(writebytesTask, (signed char *) "Task0", 100, (void *) 0, 1, NULL);
xTaskCreate(writebytesTask, (signed char *) "Task1", 100, (void *) 1, 1, NULL);
vTaskStartScheduler();
while(1){}
}
void writebytesTask(void *params)
{
long i = (long) params;
while (1) {
USART2->DR = i;
while (!(USART2->SR & USART_FLAG_TC)) {}
}
}
I have left out the definition of configureUSART2(), but I have tested it and know it works properly. When I flash this to my board (Olimex STM32-H107), I get no bytes sent out on USART2. When I run OpenOCD and gdb to see what is going on, I can step through each line, up to the call to vTaskStartScheduler(). After that point, it doesn’t return (as expected), but no data is sent out either. When I hit CTRL-C in gdb to halt it, I get this:
Program received signal SIGINT, Interrupt.
WWDG_IRQHandler () at /home/luke/repos/roboticbicycle/MCP/src/startup_STM32F10X_CL.s:112
I haven’t implemented WWDG_IRQHandler(), it is aliased to the Default_Handler in the startup assembly code (provided by STM and unmodified by me).
If I remove all the FreeRTOS code and replace the tasks with a single simple while loop that simply writes to USART2->DR and waits for the transmission to complete, I receive a continuous stream of data on the machine that I have connected to the Olimex board, so I am confident that this isn’t merely some communication configuration problem.
What might be going on here and what am I doing wrong? Any ideas on how to debug this? I’m new to FreeRTOS and am not sure exactly how to debug things once the scheduler has started (any tips/pointers on this would be welcome).
Thanks,~Luke