Hello all, I'm new to FreeRTOS. Im currently working with ST32F072RB Discovery board. I integrated the FreeRTOS with my test code. Im not using CubeMx, HAL library or Std Peripheral Lib. When running the code, it gets stuck at prvTaskExitError(). Here is my code
~~~
int main()
{
//Set priority of SYSTick
NVICEnableIRQ(SysTickIRQn);
NVICSetPriority(SysTickIRQn, 3);
/* Clock checkin code *******************************************************************/
//Clock checking
coreClock_1 = SystemCoreClock; / Store value of predefined SystemCoreClock /
SystemCoreClockUpdate(); / Update SystemCoreClock according to register settings /
coreClock_2 = SystemCoreClock; / Store value of calculated SystemCoreClock /
if (coreClock2 != coreClock1)
{
/ Without changing the clock setting both core clock values should be the same /
// Error Handling
}
//returnCode = SysTick_Config(SystemCoreClock / 1000); / Configure SysTick to generate an interrupt every millisecond */
/******************************************************************************************/
/* Initialization ***************************************************************************/
GPIO_Init();
UART1_Init();
UART_HandleInit(&huart);
ADC1_Init();
/* Debug purpose */
if(DEBUG == 1)
{
printf("UART1 test string \r\n");
printf("This is sample ADC code \r\n");
printf("ADC1 used USART1 used \r\n");
}
printf("INITILIZATION DONE \r\n");
RTOS();
while(1)
{
}
}
void RTOS() { xTaskCreate(vTaskFunction1, "Task 1", 128, NULL, 2, NULL);
vTaskStartScheduler();
while(1)
{
}
}
/* Implementation of vTaskFunction----------------------------------------*/ void vTaskFunction1( void *pvParameters) { //Start the ADC conversion ADC1_Start();
printf("ADC Value: %d \r\n",ADC_Value);
//Get the conversion value
onTime = ADC_Value;
//PWM code
offTime = 4096 - onTime;
GPIOC->BSRR |= 0x0040; //Set Red LED
for(i = 0; i < onTime; i++)
{
__ASM("nop");
}
GPIOC->BRR |= 0x0040; //Reset Red LED
for(i = 0; i < offTime; i++)
{
__ASM("nop");
}
}
~~~
Here is my FreeRTOSConfig.h ~~~ /* Ensure stdint is only used by the compiler, and not the assembler. */
#include <stdint.h>
extern uint32_t SystemCoreClock;
//#define configCHECKFORSTACK_OVERFLOW 2
//#define configUSEMALLOCFAILED_HOOK 1
/* Co-routine definitions. */
/* Software timer definitions. */ //#define configUSETIMERS 1 //#define configTIMERTASKPRIORITY ( 2 ) //#define configTIMERQUEUELENGTH 5 //#define configTIMERTASKSTACKDEPTH ( 80 )
/* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */
/* Normal assert() semantics without relying on the provision of an assert.h header file. */
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS standard names - or at least those used in the unmodified vector table. */
~~~
The code gets stuck here, in port.c (indicated by >>) ~~~ static void prvTaskExitError( void ) { /* A function that implements a task must not exit or attempt to return to its caller as there is nothing to return to. If a task wants to exit it should instead call vTaskDelete( NULL ).
Artificially force an assert() to be triggered if configASSERT() is
defined, then stop here so application writers can catch the error. */
>>configASSERT( uxCriticalNesting == ~0UL );
portDISABLE_INTERRUPTS();
for( ;; );
} ~~~
Im also using ADC1 and USART1 Interrupts. Both have priority 0.
On Serial port im getting the output >> UART1 test string >> This is sample ADC code >> ADC1 used USART1 used >> INITILIZATION DONE >> ADC Value: 0
The task is not running repeatedly.
Unfortunately there is a lot wrong with this code. The first place to start would probably be the following link, so you can see how to structure a task:
http://www.freertos.org/implementing-a-FreeRTOS-task.html
After that the following links might help:
http://www.freertos.org/FreeRTOS-quick-start-guide.html
http://www.freertos.org/Creating-a-new-FreeRTOS-project.html