problems porting FreeRTOS on AVR atmega328p

I’M trying to get my first run with FreeRTOS on AVR chips.
I have an atmega328p, which is very similar to atmega323. I’m testing on the stk500v2 board.
According to the documentation, I’m making small changes in port.c, resume with a diff :
`diff ./Source/portable/GCC/ATMega323/port.c …
416c416
< ucLowByte = TIMSK;
> ucLowByte = TIMSK1;
418c418
< TIMSK = ucLowByte;
> TIMSK1 = ucLowByte;`
I see some errors in the test code due to serial port differences, so I change some ref :
`103c103
< ucByte = UCSRB;
> ucByte = UCSR0B;
105c105
< UCSRB = ucByte;
> UCSR0B = ucByte;
113c113
< ucInByte = UCSRB;
> ucInByte = UCSR0B;
115c115
< UCSRB = ucInByte;
> UCSR0B = ucInByte;
136c136
< UBRRL = ucByte;
> UBRR0L = ucByte;
140c140
< UBRRH = ucByte;
> UBRR0H = ucByte;
144c144
< UCSRB = ( serRX_INT_ENABLE | serRX_ENABLE | serTX_ENABLE );
> UCSR0B = ( serRX_INT_ENABLE | serRX_ENABLE | serTX_ENABLE );
147c147
< UCSRC = ( serUCSRC_SELECT | serEIGHT_DATA_BITS );
> UCSR0C = ( serUCSRC_SELECT | serEIGHT_DATA_BITS );
206c206
< ucByte = UCSRB;
> ucByte = UCSR0B;
208c208
< UCSRB = ucByte;
> UCSR0B = ucByte;
222c222
< cChar = UDR;
> cChar = UDR0;
240c240
< UDR = cChar;
> UDR0 = cChar;`
After that, I can compile the demo :
`Size after:
rtosdemo.elf  :
section     size      addr
.data         80   8388864
.text       9880         0
.bss        1665   8388944
.stab      32016         0
.stabstr   15741         0
Total      59382
Errors: none
—– end —–`
But after uploading the code, It doesn’t work… no led flashing or signal on serial port.
Does anyone experiencing such problem? I don’t see what other difference between m323/3328 I have to code.

problems porting FreeRTOS on AVR atmega328p

oups… sorry for the "code" section

problems porting FreeRTOS on AVR atmega328p

I cannot read the posted code, but can you say some more about what happens when you try running the application? How far does the code get?

problems porting FreeRTOS on AVR atmega328p

Here is the FreeRTOS/Source/portable/GCC/ATMega323/port.c diff
416c416

< ucLowByte = TIMSK;

> ucLowByte = TIMSK1;
418c418

< TIMSK = ucLowByte;

> TIMSK1 = ucLowByte;

problems porting FreeRTOS on AVR atmega328p

FreeRTOS/Source/portable/GCC/ATMega323/port.c
    416c416
    < ucLowByte = TIMSK;
    —
    $gt; ucLowByte = TIMSK1;
    418c418
    < TIMSK = ucLowByte;
    —
    > TIMSK1 = ucLowByte;

problems porting FreeRTOS on AVR atmega328p

`
FreeRTOS/Source/portable/GCC/ATMega323/port.c 
416c416 
< ucLowByte = TIMSK; 
— 
> ucLowByte = TIMSK1; 
418c418 
< TIMSK = ucLowByte; 
— 
> TIMSK1 = ucLowByte; 
`

problems porting FreeRTOS on AVR atmega328p

FreeRTOS/Source/portable/GCC/ATMega323/port.c : 
    416c416 
    < ucLowByte = TIMSK; 
    > ucLowByte = TIMSK1; 
    418c418 
    < TIMSK = ucLowByte; 
    > TIMSK1 = ucLowByte; 

problems porting FreeRTOS on AVR atmega328p

Sorry for the post I’m not good with the post language.   
   
At the end, the port.c and serial.c mod to compile the demo for atmega328.
When I re-start after program the chip, nothing is happend, no led flashing, no data on serial spare port…   
   
FreeRTOS/Source/portable/GCC/ATMega323/port.c : 
    416c416 
    < ucLowByte = TIMSK; 
    > ucLowByte = TIMSK1; 
    418c418 
    < TIMSK = ucLowByte; 
    > TIMSK1 = ucLowByte; 
   
FreeRTOS/Demo/AVR_ATMega323_WinAVR/serial/serial.c :
103c103
    < ucByte = UCSRB;
    > ucByte = UCSR0B;
    105c105
    < UCSRB = ucByte;
    > UCSR0B = ucByte;
    113c113
    < ucInByte = UCSRB;
    > ucInByte = UCSR0B;
    115c115
    < UCSRB = ucInByte;
    > UCSR0B = ucInByte;
    136c136
    < UBRRL = ucByte;
    > UBRR0L = ucByte;
    140c140
    < UBRRH = ucByte;
    > UBRR0H = ucByte;
    144c144
    < UCSRB = ( serRX_INT_ENABLE | serRX_ENABLE | serTX_ENABLE );
    > UCSR0B = ( serRX_INT_ENABLE | serRX_ENABLE | serTX_ENABLE );
    147c147
    < UCSRC = ( serUCSRC_SELECT | serEIGHT_DATA_BITS );
    > UCSR0C = ( serUCSRC_SELECT | serEIGHT_DATA_BITS );
    206c206
    < ucByte = UCSRB;
    > ucByte = UCSR0B;
    208c208
    < UCSRB = ucByte;
    > UCSR0B = ucByte;
    222c222
    < cChar = UDR;
    > cChar = UDR0;
    240c240
    < UDR = cChar;
    > UDR0 = cChar;

problems porting FreeRTOS on AVR atmega328p

Sorry for the post I’m not good with the post language.   
   
At the end, the port.c and serial.c mod to compile the demo for atmega328.
When I re-start after program the chip, nothing is happend, no led flashing, no data on serial spare port…   
   
FreeRTOS/Source/portable/GCC/ATMega323/port.c : 
    416c416 
    < ucLowByte = TIMSK; 
    > ucLowByte = TIMSK1; 
    418c418 
    < TIMSK = ucLowByte; 
    > TIMSK1 = ucLowByte; 
   
FreeRTOS/Demo/AVR_ATMega323_WinAVR/serial/serial.c : 
103c103 
    < ucByte = UCSRB; 
    > ucByte = UCSR0B; 
    105c105 
    < UCSRB = ucByte; 
    > UCSR0B = ucByte; 
    113c113 
    < ucInByte = UCSRB; 
    > ucInByte = UCSR0B; 
    115c115 
    < UCSRB = ucInByte; 
    > UCSR0B = ucInByte; 
    136c136 
    < UBRRL = ucByte; 
    > UBRR0L = ucByte; 
    140c140 
    < UBRRH = ucByte; 
    > UBRR0H = ucByte; 
    144c144 
    < UCSRB = ( serRX_INT_ENABLE | serRX_ENABLE | serTX_ENABLE ); 
    > UCSR0B = ( serRX_INT_ENABLE | serRX_ENABLE | serTX_ENABLE ); 
    147c147 
    < UCSRC = ( serUCSRC_SELECT | serEIGHT_DATA_BITS ); 
    > UCSR0C = ( serUCSRC_SELECT | serEIGHT_DATA_BITS ); 
    206c206 
    < ucByte = UCSRB; 
    > ucByte = UCSR0B; 
    208c208 
    < UCSRB = ucByte; 
    > UCSR0B = ucByte; 
    222c222 
    < cChar = UDR; 
    > cChar = UDR0; 
    240c240 
    < UDR = cChar; 
    > UDR0 = cChar; 
 

problems porting FreeRTOS on AVR atmega328p

I just try with an another AVR, atmega32. I just change the makefile parameters, and it works (3 blinking leds + 2 serial port transmission leds) ! So I can exclude a problem on the stk500 and harware config. I recheck the atmega328 spec, but I don’t fine where the problem come from.

problems porting FreeRTOS on AVR atmega328p

Did you check these items at the top of port.c:     /* 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 ) 0x02 ) These are what worked on my 1284p.  Point is, you may need to check these.  I don’t know that this is right, just something else to check. kd5uwl

problems porting FreeRTOS on AVR atmega328p

That’s right, the interrupt comparator enable bit is not the same. And the interrupt vector name is not same. The final "port.c" is here. There is also problems with the serial port, but with the relevant tasks commented in main.c, it works.     
     
diff -r FreeRTOS/Source/portable/GCC/ATMega323/port.c …     
80c80     
< #define portCOMPARE_MATCH_A_INTERRUPT_ENABLE ( ( unsigned char ) 0x10 )     
> #define portCOMPARE_MATCH_A_INTERRUPT_ENABLE ( ( unsigned char ) 0x02 )     
416c416     
< ucLowByte = TIMSK;     
> ucLowByte = TIMSK1;     
418c418     
< TIMSK = ucLowByte;     
> TIMSK1 = ucLowByte;     
429,430c429,430     
< void SIG_OUTPUT_COMPARE1A( void ) __attribute__ ( ( signal, naked ) );     
< void SIG_OUTPUT_COMPARE1A( void )     
> void TIMER1_COMPA_vect( void ) __attribute__ ( ( signal, naked ) );     
> void TIMER1_COMPA_vect( void )