Atmel website | ARM Community | AVR freaks | Technical Support
Banner
Welcome to AT91SAM Community Forum
http://www.at91.com/samphpbb/

Bloated stack for simple code?
http://www.at91.com/samphpbb/viewtopic.php?f=8&t=1898
Page 1 of 1

Author:  Adam [ Tue Jun 13, 2006 4:53 pm ]
Post subject:  Bloated stack for simple code?

Hi guys,

Currently using an AT91SAM7A3 which is executing a very simple piece of code in a for(;;) loop (why are they more efficient than while(1)'s??). At the moment the funtion basically looks like:

// configure the PIO Lines corresponding to LED1 to LED4
// to be outputs. No need to set these pins to be driven by the PIO because it is GPIO pins only.
AT91F_PIO_CfgOutput( AT91C_BASE_PIOA, LEDX->m_LedAddress ) ;

// Clear the LED's. On the we must apply a "1" to turn off LEDs
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LEDX->m_LedAddress ) ;

for(;;)
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LEDX->m_LedAddress) ;
//wait();
OSS_SleepMillisecs(LEDX->m_LedSpeedms);
//debug_uart->SendNullTermCharArray((UINT8*)"L1\r\n");
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LEDX->m_LedAddress ) ;
//wait();
OSS_SleepMillisecs(LEDX->m_LedSpeedms);
//debug_uart->SendNullTermCharArray((UINT8*)"L0\r\n");
}

The OSS_SleepMillisecs is just a map to an operating system millisec sleep function. For some reason this code is using the best part of 287 bytes of stack. That seems extreme for something so simple. The most concerning thing is that most of this is used on the first inline function call ( AT91F_PIO_CfgOutput( AT91C_BASE_PIOA, LEDX->m_LedAddress ) ;) Any ideas as to why? I've never really looked into stack usage before... If anyone has any good resources for understanding this I'd appreciate it.

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/