2008-09-15 07:58 AM
GCC problem with Standby and WFI
2011-05-17 03:45 AM
I've been having good luck developing for the STM32F101 with the GCC toolchain from Anglia, but I've run into a snag with an apparent bug, (or operator error), relating to the Standby function.
Below is a simple program using the 8MHz HSI that turns on an LED for a couple of seconds, then goes into standby. At this point, all the processor outputs should be tri-stated, so the LED should go off. A rising edge on the PA0 pin should wake it up. It works fine using the IAR 4.42A KickStart GUI, but not with GCC 4.2.0. The LED just stays on constantly, and the processor apparently crashes when trying to execute the __WFI() and never makes it into standby. Here's the code, and my gcc command lines, any help or comments would be appreciated. // MAIN.c #include ''stm32f10x_lib.h'' int main(void) { volatile int i; GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE); // PortE-15 drives a LED GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 ; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOE, &GPIO_InitStructure); // Enable PWR and BKP clock RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); // Enable PA0 wakeup behavior PWR_WakeUpPinCmd(ENABLE); // Turn on a LED for a couple of seconds GPIO_SetBits(GPIOE, GPIO_Pin_15); for (i = 1600000; i>0; ) {i--;} // Go into Standby mode, and LED should turn off // Rising edge on PA0 should be able to wake it up PWR_EnterSTANDBYMode(); while(1) {} } Here's my gcc command lines: gcc -mthumb -mcpu=cortex-m3 -Wall -Os -std=c99 -save-temps -fno-strict-aliasing -c -I. -iquote ../../../../../Code/library/inc main.c -o obj/main.o gcc -mthumb -mcpu=cortex-m3 -Wall -Os -std=c99 -save-temps -c -I. -iquote ../../../../../Code/library/inc stm32f10x_it.c -o obj/stm32f10x_it.o gcc -mthumb -mcpu=cortex-m3 -Wall -Os -std=c99 -save-temps -c -I. -iquote ../../../../../Code/library/inc startup.c -o obj/startup.o gcc -mthumb -mcpu=cortex-m3 -T./stm32rom.ld -Wl,-Map=obj/lpstandby.map,-cref,--gc-sections -o obj/lpstandby.elf -nostartfiles obj/main.o obj/stm32f10x_it.o obj/startup.o -lstm32d To other gcc users, does this work on your system? What command lines/versions are you using? Thanks, Bruce2011-05-17 03:45 AM
Fixed.
Updated to Anglia STRx Toolchain 1.62 (Gcc 4.2.3). http://www.st-angliamicro.com/software.asp2011-05-17 03:45 AM
Bruce-
Your use of dual toolchains has highlighted an unexpected benefit - the identification of toolchain-specific errors or weaknesses. When both toolchains ''approve'' your code it is likely that your usage and references are ''expected'' and correct. When a single toolchain ''squawks'' it may be that the errant function is new/unusual - and that the function has not yet been properly resolved - or that your usage is non-standard. Thanks for identifying the problem AND its solution...2011-05-17 03:45 AM
Quote:
It works fine using the IAR 4.42A KickStart GUI, but not with GCC 4.2.0.
Quote:
Fixed.
Updated to Anglia STRx Toolchain 1.62 (Gcc 4.2.3).Do you know if it's a general issue with GCC 4.2.0, fixed by GCC 4.2.3, or is it something specific to the Anglia implementation of GCC 4.2.0 ?2011-05-17 03:45 AM
No, I don't. I just loaded the updated 4.2.3, and it finally worked as it should.
If you have 4.2.0, maybe you could try building it yourself and see. Perhaps the problem was somehow with my installation? Bruce