[ECOS] Cortex M3 idle sleep

Nick Garnett nickg@ecoscentric.com
Fri Feb 13 16:08:00 GMT 2009

Simon Kallweit <simon.kallweit@intefo.ch> writes:

> Hello
> Would it make sense to include support for sleeping ("wfi"
> instruction) in idle thread for the cortex m3 architecture? The
> current code in hal_arch.h looks like:
> #define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )
> #else
> #endif
> I guess this is not what it was meant to be. I would propose to add an option like CYGHWR_HAL_CORTEXM_IDLE_SLEEP to enable the wfi instruction:
> #  define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )
> # else
> # endif
> #endif
> Also, currently var_arch.h gets not included in the hal_arch.h header, so it's impossible to override for example the HAL_IDLE_THREAD_ACTION macro. I guess this was just overlooked, or is it intentional?
> I can provide a patch if there are no objections.

The "#if 0" is an oversight on my part. When debugging via JTAG I was
having difficulties breaking in to an idle system. Stopping it using
WFI solved this. The #else part is also a consequence of this, so that
code should really be:

#define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )

Given this I don't really see any need for the
CYGHWR_HAL_CORTEXM_IDLE_SLEEP option. If a variant or platform HAL
needs to override this it can very easily by redefining

var_arch.h should certainly be included in hal_arch.h. It is only
because the STM32 has an empty var_arch.h that we haven't noticed this

Nick Garnett                                        eCos Kernel Architect
eCosCentric Limited    http://www.eCosCentric.com        The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales:                          Reg No: 4422071
Besuchen Sie uns vom 3.-5.03.09 auf der Embedded World 2009, Stand 11-300
Visit us at Embedded World 2009, Nürnberg, Germany, 3-5 Mar, Stand 11-300

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list