Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists