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

Problems with vTaskDelay on Atmel 644

Posted by Fallback on October 10, 2007
Hi folks,

at first thanks for this great os, really nice. So we're using freertos on an atmel 644 and facing some problems right now.

We want to start very simple so we took the sample application with vTaskCreate and vTaskDelay.
Something like that:

void vTask1( void * pvParameters ) {
for(;;)
{
/* whatever */
vTaskDelay(100);
}
}

When we call vTaskDelay(100) the first task gets canceled but the second vTask2 is never started. :(
So we figured out that it has something to do with the value for the timers, especially TIMSK?!

Can somebody tell us which values and header files we need to include for the atmega 644?

Thanks alot for your support,
Tobias

RE: Problems with vTaskDelay on Atmel 644

Posted by sotd on October 10, 2007
What are the differences between the 644 and the 32? Does the 644 have the extended architecture with three program counter bytes? There was some talk about this before some time ago.

RE: Problems with vTaskDelay on Atmel 644

Posted by t4z on October 10, 2007
Hi there,

i belong to tobias. So i would like to join the conversation.

@sotd

I dont know, if you are speaking of that what i am thinking of. On the Atmel site we found an application sheet called "Migration between ATmega 16/32 and ATmega 164P/324P/644(P)".

http://www.atmel.com/dyn/resources/prod_documents/doc8001.pdf

On site 4 we realized, that there are TIMSK0,TIMSK1 and TIMSK2 for the ATmega644 instead of TIMSK for the ATmega 16/32. Cause we are not so experienced in ┬Ác programming, we dont know what we have to implement into the "port.c". Actually the prvSetupTimerInterrupt()looks like the following.

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/*
* Setup timer 1 compare match A to generate a tick interrupt.
*/
static void prvSetupTimerInterrupt( void )
{
unsigned portLONG ulCompareMatch;
unsigned portCHAR ucHighByte, ucLowByte;

/* Using 16bit timer 1 to generate the tick. Correct fuses must be
selected for the configCPU_CLOCK_HZ clock. */

ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ;

/* We only have 16 bits so have to scale to get our required tick rate. */
ulCompareMatch /= portCLOCK_PRESCALER;

/* Adjust for correct value. */
ulCompareMatch -= ( unsigned portLONG ) 1;

/* Setup compare match value for compare match A. Interrupts are disabled
before this is called so we need not worry here. */
ucLowByte = ( unsigned portCHAR ) ( ulCompareMatch & ( unsigned portLONG ) 0xff );
ulCompareMatch >>= 8;
ucHighByte = ( unsigned portCHAR ) ( ulCompareMatch & ( unsigned portLONG ) 0xff );
OCR1AH = ucHighByte;
OCR1AL = ucLowByte;

/* Setup clock source and compare match behaviour. */
ucLowByte = portCLEAR_COUNTER_ON_MATCH | portPRESCALE_64;
TCCR1B = ucLowByte;

/* Enable the interrupt - this is okay as interrupt are currently globally
disabled. */
ucLowByte = TIMSK;
ucLowByte |= portCOMPARE_MATCH_A_INTERRUPT_ENABLE;
TIMSK = ucLowByte;
}
/*-----------------------------------------------------------*/
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Everytime vTaskDelay() is called the os hang up, so it seems that the scheduler coudnt work right because of a wrong configuration of the timers or something else.

I think, we really need some suggestions or help at that point. :\

Thanks in advance,

Chris

RE: Problems with vTaskDelay on Atmel 644

Posted by Dave on October 11, 2007
I think you are right to suspect the timer if you are never leaving a call to vTaskDelay.

I would suggest writing a very simple program that just setups up a timer interrupt and does nothing else. Not using FreeRTOS. Once you have proven that the timer interrupt is running correctly you can update the prvSetupTimerInterrupt() function in FreeRTOS if you have found that changes are required for your particular micro, then try your app again.

RE: Problems with vTaskDelay on Atmel 644

Posted by Fallback on October 11, 2007
Hey,

thanks for your answers. So we are now trying to build a little timer sample app, we'll see if it works.

So for our TIMSK problem, we found out that the 644 has not only one timer (TIMSK) but three (TIMSK0, TIMSK1 and TIMSK2). They all are defined correctly in the iomxx4.h.
But there are a few lines of code in the port.c that cause some trouble:

/* Enable the interrupt - this is okay as interrupt are currently globally
disabled. */
ucLowByte = TIMSK;
ucLowByte |= portCOMPARE_MATCH_A_INTERRUPT_ENABLE;
TIMSK = ucLowByte;
}

Cause we have no TIMSK and just renaming to TIMSK0 1 or 2 is not working. :(

I think that there must be some other command to enable the timer interupts on the 644, am I right?
And does anyone know this command? ;)

Thx alot,
Tobias


RE: Problems with vTaskDelay on Atmel 644

Posted by t4z on October 11, 2007
And hey again,

hmm the standard for the avr323 looks like that

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/*-----------------------------------------------------------
* Implementation of functions defined in portable.h for the AVR port.
*----------------------------------------------------------*/

/* Start tasks with interrupts enables. */
#define portFLAGS_INT_ENABLED( ( portSTACK_TYPE ) 0x80 )

/* Hardware constants for timer 1. */
#define portCLEAR_COUNTER_ON_MATCH( ( unsigned portCHAR ) 0x08 )
#define portPRESCALE_64( ( unsigned portCHAR ) 0x03 )
#define portCLOCK_PRESCALER( ( unsigned portLONG ) 64 )
#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE( ( unsigned portCHAR ) 0x10 )

/*-----------------------------------------------------------*/
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

We looked into the datasheet for the AtMega644 and changed it to the following:

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/*-----------------------------------------------------------
* Implementation of functions defined in portable.h for the AVR port.
*----------------------------------------------------------*/
/* Start tasks with interrupts enables. */
#define portFLAGS_INT_ENABLED ( ( portSTACK_TYPE ) 1<<ICIE1 )

/* Hardware constants for timer 1. */
#define portCLEAR_COUNTER_ON_MATCH ( unsigned portCHAR ) 1<<WGM12 )
#define portPRESCALE_64 ( ( unsigned portCHAR ) (1<<CS12)|(1<<CS10) )
#define portCLOCK_PRESCALER ( ( unsigned portLONG ) 64 )
#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE ( ( unsigned portCHAR )1<<OCIE1A)
/*-----------------------------------------------------------*/
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

TIMSK we changed to TIMSK1 (16 Bit Register).

The result is, the OS still hang up. :(


RE: Problems with vTaskDelay on Atmel 644

Posted by Fallback on October 16, 2007
Yeah! We found the problem.
The changes for the Atmega644 are as following:

port.c
--------------------------------------------------------------------------------------
#define portFLAGS_INT_ENABLED ( ( portSTACK_TYPE ) 0x80 )

#define portCLEAR_COUNTER_ON_MATCH( ( unsigned portCHAR ) 0x08 )
#define portPRESCALE_64( ( unsigned portCHAR ) 0x05 )
#define portCLOCK_PRESCALER( ( unsigned portLONG ) 64 )
#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE( ( unsigned portCHAR ) 0x02 )

static void prvTimerInterrupt( void )

/* Enable the interrupt - this is okay as interrupt are currently globally
disabled. */
ucLowByte = TIMSK1;
ucLowByte |= portCOMPARE_MATCH_A_INTERRUPT_ENABLE;
TIMSK1 = ucLowByte;
--------------------------------------------------------------------------------------

Now the TaskDelay() function works quite fine.

We keep you updated on our port for the 644. :)

Cya,
Tobias


[ 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