Reply by Richard June 22, 20042004-06-22
Hi again,

The stack size required by a task is the same no matter how much RAM you
have available.  Less RAM just means fewer tasks.

See http://www.FreeRTOS.org/a00111.html, but bare in mind that the use of
malloc and free can require some configuration on low end microcontrollers.

Regards,
Richard.

http://www.FreeRTOS.org



"sap" <mbox.nospam@cloppy.net> wrote in message
news:cb7sse$nb4$1@biggoron.nerim.net...
> > > Is there something else than portMINIMAL_STACK to tweak for 1k RAM? > > > > > > Ok, I see: inside portheap.c. > For the time being I fell pretty confortable, small tasks are running and > the remaining will sure be more clear during comming days. > Regards > > /*----------------------------------------------------------- > > * Very basic block allocation scheme. This is tailored exactly for the
demo
> > * application needs and should be tuned or replaced for any other > application. > > *----------------------------------------------------------*/ > > /* Compiler include files. */ > > #include <stdlib.h> > > /* Scheduler include files. */ > > #include "projdefs.h" > > #include "portable.h" > > #define heapSMALL_BLOCK_SIZE ( ( unsigned portSHORT ) 45 ) > > #define heapLARGE_BLOCK_SIZE portMINIMAL_STACK_SIZE > > /* These are the number of blocks required by the demo application. */ > > #define heapNUM_SMALL_BLOCKS ( 16 ) > > #define heapNUM_LARGE_BLOCKS ( 10 ) > > /* Each block contains the data area and a variable that marks the block
as
> > empty of full. */ > >
Reply by sap June 21, 20042004-06-21
> Is there something else than portMINIMAL_STACK to tweak for 1k RAM? > >
Ok, I see: inside portheap.c. For the time being I fell pretty confortable, small tasks are running and the remaining will sure be more clear during comming days. Regards /*----------------------------------------------------------- * Very basic block allocation scheme. This is tailored exactly for the demo * application needs and should be tuned or replaced for any other application. *----------------------------------------------------------*/ /* Compiler include files. */ #include <stdlib.h> /* Scheduler include files. */ #include "projdefs.h" #include "portable.h" #define heapSMALL_BLOCK_SIZE ( ( unsigned portSHORT ) 45 ) #define heapLARGE_BLOCK_SIZE portMINIMAL_STACK_SIZE /* These are the number of blocks required by the demo application. */ #define heapNUM_SMALL_BLOCKS ( 16 ) #define heapNUM_LARGE_BLOCKS ( 10 ) /* Each block contains the data area and a variable that marks the block as empty of full. */
Reply by sap June 21, 20042004-06-21
Hi,

> 2) The ATMega8 only has 1K of RAM. Have you adjusted the memory pool
sizes? That was my error as I wrote yesterday. It works much better with 45 bytes per task. #define portMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 45 ) Is this what you mean the pool or are there other parameters?
> Are you absolutely sure the task is being created, it might not be if the > allocation is failing?
That was checked by toggling LED state. Allocation succeeded even for very short stack sizes but tasks could not run.
> 3) Have you tried running the code in the simulator that comes with AVR > Studio (this is free for download from the Atmel site). This should allow > you to see exactly what is going on.
I have to learn how to use it... I will.
> 4) Have you read the instructions on the WEB site regarding using other > devices? In addition you will need to change the included header file at > the top of Source\portable\GCC\ATMega323\portmacro.h from the ATMega323 > header file to the ATMega8 header file.
Was done. In fact, I've read all the source and learned a lot :-)
> 6) portMINIMAL_STACK should be around 80 - definately not between 5 and
20 -
> it has to hold 30 registers!
I thought less RAM would mean lower stack size... Is there something else than portMINIMAL_STACK to tweak for 1k RAM?
> If you are still having difficulties - email me directly using the address > on the FreeRTOS WEB site contact page. If you send me your test program > project (all files including makefile, etc.) I will be able to help you
out.
> > Regards, > Richard. > > http://www.FreeRTOS.org >
many thanks :-)
Reply by Richard June 19, 20042004-06-19
> Did anyone succeede using FreeRTOS on ATMega8?
A couple of things: 1) Have you tested your LED initialisation code in isolation? If you write a simple main() function as per .... : portSHORT main( void ) { unsigned portSHORT s; outp( 0x04, DDRB ); outp( 0x00, DDRC ); outp( 0x00, DDRD ); outp( 0xff, PORTB ); outp( 0xff, PORTC ); outp( 0xff, PORTD ); for(;;) { /* Crude delay. */ for( s = 0; s < 999; s++ ); cbi( PORTB, 2 ); /* Crude delay. */ for( s = 0; s < 9999; s++ ); sbi( PORTB, 2 ); } } .... does the LED flash? 2) The ATMega8 only has 1K of RAM. Have you adjusted the memory pool sizes? Are you absolutely sure the task is being created, it might not be if the allocation is failing? 3) Have you tried running the code in the simulator that comes with AVR Studio (this is free for download from the Atmel site). This should allow you to see exactly what is going on. 4) Have you read the instructions on the WEB site regarding using other devices? In addition you will need to change the included header file at the top of Source\portable\GCC\ATMega323\portmacro.h from the ATMega323 header file to the ATMega8 header file. 6) portMINIMAL_STACK should be around 80 - definately not between 5 and 20 - it has to hold 30 registers! If you are still having difficulties - email me directly using the address on the FreeRTOS WEB site contact page. If you send me your test program project (all files including makefile, etc.) I will be able to help you out. Regards, Richard. http://www.FreeRTOS.org
Reply by sap June 19, 20042004-06-19
Hi,

Did anyone succeede using FreeRTOS on ATMega8?

I changed main.c from the ATMega323 demo expecting to get a LED on PORTB.2
blinking but this most don't work. Idle and Flashing threads start (at least
code is entered) but I do not get the LED blinking whatever my routine is. I
have not much debug tools...

I tried to tweak parameters in portmacro.h (portMAX_PRIORITIES to 1,
portMINIMAL_STACK_SIZE between 5 and 20) but this does not bring the code to
work.

Below you will find main.c.

Regards



#include <stdlib.h>
#include <string.h>

#include "projdefs.h"
#include "portable.h"
#include "task.h"

static void vLEDFlashTask( void *pvParameters );

portSHORT main( void )
{
 outp( 0x04, DDRB );
 outp( 0x00, DDRC );
 outp( 0x00, DDRD );

 outp( 0xff, PORTB );
 outp( 0xff, PORTC );
 outp( 0xff, PORTD );

 sTaskCreate( vLEDFlashTask, ( const portCHAR * const ) "LEDx",
portMINIMAL_STACK_SIZE, NULL, 1, ( xTaskHandle * ) NULL );

 vTaskStartScheduler( portUSE_PREEMPTION );

 return 0;
}

static void vLEDFlashTask( void *pvParameters )
{
 for(;;)
 {
  portTickType xFlashRate = ( portTickType ) 200;
  xFlashRate /= portTICKS_PER_MS;
  xFlashRate /= ( portTickType ) 2;

  cbi( PORTB, 2 );
  vTaskDelay( xFlashRate );
  sbi( PORTB, 2 );
  vTaskDelay( xFlashRate );
 }
}