Problems with vTaskDelay on Atmel 644

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

Problems with vTaskDelay on Atmel 644

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.

Problems with vTaskDelay on Atmel 644

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

Problems with vTaskDelay on Atmel 644

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.

Problems with vTaskDelay on Atmel 644

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

Problems with vTaskDelay on Atmel 644

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. :(

Problems with vTaskDelay on Atmel 644

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