Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 26, 2005
Hi I use a STK500 board with ATMega16L processor. I have tried the demo program with this microcontroller but nothing works. It feels like the processor is not switched on at all. (I mjean no visual indication on leds connected to portb or activity on the serial port.)

I know the processor is fine as my program using the serial port works fine. I have changed the value of configTOTAL_HEAP_SIZE from 1500 to 800 to accomodate for the 1kByte of SRAM in the mega16. Are there any other changes i need to make? I am running the processor at 8MHz.

RE: ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 26, 2005
The demo application uses all the heap - so if you have reduced the heap size it is likely that the scheduler is running out of memory and not starting.

Try reducing the number of tasks that are created - in FreeRTOS/Demo/AVR_ATMega323_WinAVR/main.c comment out the lines:

vStartIntegerMathsTasks()
vAltStartComTestTasks()
vStartPolledQueueTasks()
xTaskCreate( vErrorChecks, ...

This should just leave the LED flash tasks so you can see if anything is running.

RE: ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 26, 2005
Thanks it works now! :-) But i am surprised at the number of tasks that can run in parallel with 1KByte of RAM!

Next i plan to use the ATmega128 with 4KBytes of RAM. How many tasks can i run in parallel assuming default default default stack size and Global variables not exceeding 200 bytes?

RE: ATMega323 port for ATMega16L

Posted by Richard on May 26, 2005
Take a look at this page:

http://www.freertos.org/FAQMem.html#RAMUse

it should give you a good idea of the requirements. The numbers actually come from the AVR port, but prior to the V3.0.0 release. V3.0.0 uses a bit less RAM but only very slightly.

Regards.

RE: ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 26, 2005
Also... I would like to know if anyone has ever overclocked these processors (the mega128)? What are the effects of doing so?

RE: ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 26, 2005
That sounds fun :-)

I have on occassion overclocked various devices and bus systems and normally it still works. This is of coarse using the device out of specification so would not be a good idea for a commercial product.

RE: ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 27, 2005
My current setup is like this...

portSHORT main( void )
{
//prvIncrementResetCount();

/* Setup the LED's for output. */
vParTestInitialise();

//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 );

/* In this port, to use preemptive scheduler define configUSE_PREEMPTION
as 1 in portmacro.h. To use the cooperative scheduler define
configUSE_PREEMPTION as 0. */
vTaskStartScheduler();

return 0;
}

flash.c has the declaration
#define ledNUMBER_OF_LEDS( 3 )

While reducing this number is ok, increasing it to even 4 stalls the microcontroller. With this number 3 and my current main config, how many threads are running in parallel?

My guess is it is 3 for the flasing leds and 1 for the idle task. I have set the heap size to 750.

RE: ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 27, 2005
Yes - 4 tasks will be running. Can you run your code in the AVR Studio simulator? If so then step into the vTaskStartScheduler() function and see what happens. When the idle task is created you will be able to see how much RAM is left. Alternatively try filling the entire heap with a known value - then you will also be able to see in the simulator how much is left.

RE: ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 27, 2005
Try uncommenting the vStartIntegerMathTasks line. This will start just 1 extra "known good" task.

RE: ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 28, 2005
I do not have access to avr studio as i work on linux. AFAIK the flash led task does not use any additional memory consuming functions yet teh device fails to add any more than 3.

I have tried uncommenting the vStartIntegerMathTasks task but the system does not work unless i reduce the number of led flash tasks from 3 to 1. Even reducing it to 2 does not help.

RE: ATMega323 port for ATMega16L

Posted by Richard on May 29, 2005
I have tried running the project in the simulator with:

+ Stack set to 700
+ Integer math tasks
+ 3 flash tasks
+ no optimisation

and find that everything executes with no problem - and that following the creation of all the tasks (including the idle task) there are 95 bytes of stack remaining. At least enough to create another task.

Have you remembered to change the line:

MCU = atmega323

in the makefile to the correct CPU being used? Maybe there is a linker problem.

Regards.

RE: ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 29, 2005
Yes i have. The changes i have made from the demo downloaded to my setup include making

MCU = atmega16

in the makefile and,

#define configTOTAL_HEAP_SIZE( (size_t ) ( 750 ) )

in FreeRTOSConfig.h

I am using the avr tool chain on debian linux, downloaded from the debian repositories.

RE: ATMega323 port for ATMega16L

Posted by Richard on May 29, 2005
I just remembered that I had an ATMega16 lying around so gave it a go.

Having made the two changes (heap size and processor definition) I find that the program still runs with no problems, even with vStartIntegerMathTasks() uncommented.

To try and get it to go wrong I have tried full optimisation, no optimisation, with debug info and without debug info. It is happy with all these configurations.

Which version of GCC do your Linux tools use? WinAVR currently uses V3.4.3. I have used older versions also though.

Other than commenting out some of the tasks, the cpu definition and the heap size definition - have you changed any thing else?

RE: ATMega323 port for ATMega16L

Posted by Nobody/Anonymous on May 29, 2005
Now that you have mentioned, i decided unpack my downloaded FreeRTOS again check and these are the changes i made.

In FreeRTOS.h
changed ProjDefs.h to projdefs.h

In FreeRTOSConfig.h made heap size 750

In the makefile made MCU = atmega16 and setup avrdude
AVRDUDE_PROGRAMMER = stk500v2
AVRDUDE_PORT = /dev/ttyS0

These are all the changes i made. Compiled and flashed the micro and it does not execute.

I am using avr-gcc v3.4.3 and avr-libc v1.2.3


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner