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

Changes for ATMega128

Posted by Richard on July 15, 2005
[moved from older thread]

I am trying to run freeRTOS on the ATmega128 chip. I am using an ATmega128 Development Board from PRLLC (www.prllc.com). I have previous microcontroller experience with a Motorola 68HC11 chip and a PIC18LF448. However, this is my first time working with an RTOS and trying to port it to a chip.

I could use any help on setting up freeRTOS to run on this chip. I am using WinAVR v.20040404 for my development tools. I have perused the freeRTOS website, and should be able to find any reference made to it.

I have tried to make the demo program freeRTOS comes with using a make all command in Programmer's Notepad, which comes as part of the WinAVR environment. Everything compiles fine except I receive errors concerning undeclared variables in relation to serial.c

In conclusion, any help or pointing in the right direction would be much appreciated. Thank you for the time and help,

Josh Wittmier

RE: Changes for ATMega128

Posted by Richard on July 15, 2005
I know several people have FreeRTOS running on a 128, so this should not be a problem.

The compile error you see when attempting to compile for the ATMega128 is due to the fact that the ATMega128 has two serial ports so the #defined constants have slightly different names to distinguish between the two com ports.

Do you have a decent debug system that allows you to step through the code?

Here is my suggested approach:

1) Change the CPU definition at the top of the makefile – I suspect you have done this already. As downloaded it is set for “MCU = atmega323”.

2) Take a look in FreeRTOSConfig.h (same directory as the makefile) to ensure the settings are correct for your board. The clock frequency being the most likely thing that needs changing. The heap size can also be increased on the ATMega128 but don’t worry about that for now.

3) I’m hoping your demo board has some LED’s?

Take a look at the file Demo/AVR_ATMega323_WinAVR/partest/partest.c.

This file has some simple code to set, clear and toggle LED’s. The port to which the LED’s are attached is unlikely to be the same for your board as the STK500 for which this file is configured, so this will require updating. Also for now comment out the lines vTaskSuspendAll() and xTaskResumeAll(), as these cannot be used without the scheduler running.


4) Comment out the lines in serial.c that are causing you the compile problems (alternatively find the correct constants to use to correct the error).

5) Write a very simple program that just turns LED’s on and off to ensure the functions in step (3) are working. You can do this in the main.c file along the lines of:

portSHORT main( void ) // existing code
{
____prvIncrementResetCount(); // existing code

____/* Setup the LED's for output. */
____vParTestInitialise(); // existing code

____/* Add a new infinite loop here so the rest of
____the main() code never gets reached. */
____for( ;; )
____{
________unsigned long ul;

________vParTestToggleLED( 0 );
________for( ul = 0; ul < 0xfffff; ul++ );
____}
____/* Rest of code will not get executed. */



6) When you are happy that the partest files are working, put back the lines that were commented out.


7) Now we want a very simple program that does nothing but flash led’s using the kernel. In a clean main.c file (i.e. remove any code added so it is as per the download), comment out every line that creates a task other than the line that creates the ‘flash’ tasks.

//____vStartIntegerMathTasks( tskIDLE_PRIORITY );
//____vAltStartComTestTasks( mainCOM_TEST_PRIORITY, //____mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
____vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
//____vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );

//____xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );

The flash tasks should flash LED’s 0, 1 and 3 as described on the WEB site.


8) Compile the code, download, see what happens! the flash tasks should run along with the idle task.


If you can step through the code then it is best to set for cooperative scheduling (set configUSE_PREEMPTION to 0 in FreeRTOSConfig.h).

Once this very simple system is running the application can be built up.

Regards.

RE: Changes for ATMega128

Posted by Nobody/Anonymous on July 18, 2005
Thanks for the help. All of that works great.
-Josh

RE: Changes for ATMega128

Posted by Nobody/Anonymous on July 21, 2005
Porting to Mega128 I've done following things:

- created new ATMega 128 directory under potable/gcc
- copied port.c and portmacro.h from Mega323 into it
- changed timer functions to my needs (reload), I think in 2.6 you also had to change timer to timer1 etc.
- changed portable.h to include the right portmacro.h if __AVR_ATmega128__ is defined (I think this is set by gcc if you set the correct MCU value in makefile)
- copied FreeRTOSConfig.h to my project directory and customized it

I think that was all....


[ 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