Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Problem with calling Software Timer functions

Posted by account002 on August 31, 2014

Making a FreeRTOS project for TI Hercules RM48 microcontroller.

Got a problem with Software Timer functions (xTimerCreate(), xTimerReset(), xTimerStop() etc.): calling any of then inside a task causes a PREFETCH exception of the microcontroller.

Calling them inside main function is ok.

FreeRTOS v.7.4.0

Parameters from FreeRTOSConfig.h

~~~~

define configUSE_TIMERS 1
define configTIMERTASKPRIORITY ( configMAX_PRIORITIES - 2 )
define configTIMERQUEUELENGTH 10
define configTIMERTASKSTACK_DEPTH ( 128 )

~~~~

The code

~~~~

include "sys_common.h"
include "het.h"
include "gio.h"
include "FreeRTOS.h"
include "timers.h"
include "task.h"

void vTask1(void *pvParameters);

uint32 i = 0;

xTimerHandle xTimer1;

// Timer callback function void vTimerFunction(xTimerHandle xTimer) { // toggle port bits gioToggleBit(hetPORT1, i); i++; if (i>31) i=0;

// restart timer
xTimerReset(xTimer1, 0);

}

// Main function void main(void) { // configure port direction (outputs) gioSetDirection(hetPORT1, 0xFFFFFFFF); // configure port output pins initial value gioSetPort(hetPORT1, 0xFFFFFFFF);

// creating task
xTaskCreate(vTask1, (const signed char *)"TimerStart", 1024, NULL, (configMAX_PRIORITIES - 3), NULL);

vTaskStartScheduler();
while(1);

}

// Task function void vTask1(void *pvParameters) {

xTimer1 = xTimerCreate((const signed char *)"Timer1", 80 / portTICK_RATE_MS, pdFALSE, (void*) 0, vTimerFunction);
if (xTimer1 != NULL)
	xTimerReset(xTimer1, 0);

// task self-destruction
vTaskDelete( NULL );

} ~~~~

So, calling xTimerCreate causes strange error - prefetch exception. Moving block

~~~~ xTimer1 = xTimerCreate((const signed char )"Timer1", 80 / portTICKRATEMS, pdFALSE, (void) 0, vTimerFunction); if (xTimer1 != NULL) xTimerReset(xTimer1, 0); ~~~~

into the main function (for example, before vTaskStartScheduler()) makes code working properly.

What's wrong? Any ideas, please...


Problem with calling Software Timer functions

Posted by rtel on August 31, 2014
 xTaskCreate(vTask1,  (const  signed  char  *)"TimerStart",  1024,  NULL,  (configMAX_PRIORITIES  -  3),  NULL);

I assume without creating the timer you find multiple tasks execute correctly?

If so my first suggestion would have been stack overflow, but you have given vTask1 a large stack, which I'm almost certain will be fine. Worth ensuring stack overflow detection is turned on all the same though.

Your FreeRTOS version is moderately old, and I don't think a lot of the new configASSERT()s were added until V7.6.0, but it is worth ensuring that is defined too.

Is the error in xTimerCreate() or xTimerReset()? Can you step through whichever function it is and let us know on which line the problem occurs.


Problem with calling Software Timer functions

Posted by account002 on August 31, 2014

Thank you for response.

Actually the original project includes multiple tasks execution, queues, semaphores - everything works excelent. After I tried to use Software Timers and got the described error, I wrote a simple version of project, which is shown above.

vTask1 really has a large stack, furthermore in the given project it does nothing, just tries to create timer... But I'll still try to check out everything about stack and configASSERT(). Actually, need to read some documentation before...

When I try to call xTimerCreate, the error is quite strange. It's not "inside" the function. Using Assemly Step Into while calling xTimerCreate shows, that prefetch exception occures directly after uP tries to execute instruction BL xTimerCreate... (look at the attached screenshot)...

Attachments

01-TCreateError.jpg (158901 bytes)

Problem with calling Software Timer functions

Posted by rtel on August 31, 2014

I have never seen such an error. In this case I think you need to look at the address at which xTimerCreate() is located to see if it is a valid address in the hope of finding out why a simple branch instruction causes an abort. Could it be an instruction set change problem if the timers code is build to pure ARM code? If the address of the function looks valid then you will have to try and debug the abort from within the abort handler to determine why the abort occurred.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner