How to make demo work on AVR Atmega128

voidlizard wrote on Thursday, October 23, 2008:


Did anybody make the FreeRTOS Demo for on Atmega128 ?

I have the following installation:

AVR_ATMega232_WinAVR demo to use
STK500/STK501 board

Linux AVR toolchain: avr-gcc, avrdude, etc.

I have patched the demo to compile for atmega128:  some changes to use UART0 in demo’s sources, makefile to use proper platform.

So the demo is compiled and programmed OK (but with a strange PORTB LEDs blinking during the programming) and that’s all. No LED blinking, no port output.

If I try to make and program minimalistic application which blinks LED inside a cycle with linked FreeRTOS sources - it also does not work - just setup DDRB and PORTB outside the main loop (LEDs works as expexted) and it’s does not nothing in main loop (may be something is wrong with delays or so. Although it worked OK without FreeRTOS)

Sorry if it’s a silly question, but I kind a noob in embedded programming.

So could anybody point me on a minimal FreeRTOS/Atmega128 GCC example that works?

Thank you for any help,


maoru wrote on Wednesday, February 11, 2009:

I’m having the same problem on Atmega644…

maoru wrote on Wednesday, February 11, 2009:

for start, check this topic -" Using the ATmega323 port for ATmega8515" on this forum.
now leds [1:3] blinks but there still a problem (led 5 & 7 doesn’t blinks)

lamming wrote on Monday, February 23, 2009:

I’ve managed to get the leds to flash on the AT128, but still struggling with the serial port.  Has anyone cracked this yet?

lamming wrote on Tuesday, February 24, 2009:

I figured out how to port the FreeRTOS demo to the ATMega128.   Happy to share if anyone is still wondering how to do it.

circlemtn wrote on Tuesday, February 24, 2009:

I’m just starting down this road, needing the Atmega128 on Frtos - and would love to know what you’ve found.

lamming wrote on Wednesday, February 25, 2009:

Here’s what I did to get the FreeRTOS demo running on my atmega128 system.  

The LEDs on my hardware are on port C, so I had to make 4 single-character changes to ParTest.c.  They are so obvious that I’ll skip them.

I changed my tick speed.  Not sure if it matters for the demo.  So in FreeRTOSConfig.c:
#define configCPU_CLOCK_HZ            ( ( unsigned portLONG ) 7372800 )

I think the atmega323 has only one usart, but the atmega128 has two.  My hardware uses USART #1.  So I made the following file-wide substitutions to usart.c
    UDR   -> UDR1
If you use usart#0 then (I think) you can probably change "1" -> "0" in the above, but best check!

To make things a little easier for me to understand, I changed the following constants to reference the constants defined by ATMEL in the header file iom128.h.   

/* Constants for writing to UCSR1B.                                            
#define serRX_INT_ENABLE                ( ( unsigned portCHAR ) (1<<RXCIE1) )     
#define serRX_ENABLE                    ( ( unsigned portCHAR ) (1<<RXEN1) )   
#define serTX_ENABLE                    ( ( unsigned portCHAR ) (1<<TXEN1) )   
#define serTX_INT_ENABLE                ( ( unsigned portCHAR ) (1<<UDRIE1) )      // Notice that this is NOT the TX interrupt!

/* Constants for writing to UCSR1C. */
#define serUCSRC_SELECT                    ( ( unsigned portCHAR ) (1<<UCSZ00) )    // MIK
#define serEIGHT_DATA_BITS                ( ( unsigned portCHAR ) (1<<UCSZ01) )    // MIK

Finally, note that the demo sends out a bunch of characters “A…X” and expects to receive the same chars back on the serial input, and records an error if it doesn’t.  (I wonder if the test code expects a loop-back link connecting pins 2 and 3?  Does the documentation mentions that somewhere?) I connected my USART to my PC and fired up Hyperterminal to see what it did.  (Settings: 38400, 8,N and no flow control).   I typed “ABC…” and saw one of the leds toggle on/off with each input.

Hope that helps.