2011-03-28 09:38 AM
Hello everyone.
I'm trying to get the gpio's working on an external target (st32f103zd).
I'm using the Atollic Truestudio lite STM32 discovery ide.
The code i'm using works fine on the ''internal target'', the mcu on the board. Therefore i know that the gpio code is good. Also, I can debug the external mcu with swd and verify that it's working correctly.
On my external target, i've got 14.745 mhz audio crystal as HSE clock. My scope tells my it's running correctly. I can enable / disable this clock from software, although i can't get it to output any clcok synal as external (MCO) clock.It seems like everything interfacing to the outside of the mcu is not working.. I know i should enable ABP2 clocks for the gpio's to work.
Anyone have any ideas? Am I missing obvious some init stuff that doesn't get called on the external target for some reason?
Cheers,
Tim
#external-target #gpio2011-03-28 11:57 AM
We'll assume ''internal'' means simulated.
Without seeing your code or schematics, we'll guess that you're failing to set the clocks or the pin drivers for the GPIO pins, or have not wired up all the power pins on the device. If you want someone to critique your code, you'll need to post it.2011-03-29 09:30 AM
Well with ''internal'' i mean the mcu on the stm32-discovery.
It logical to assume that i'm not initializing the gpio's correctly, but the same code (the main.c at least) works on the discovery, but doesn't on the external board.
The problems seem to stem from the startup code (system_stm32f10x.c) that get's called before main().
This code sets the sysclock to use the external 8 mhz crystal (HSE) on the discovery board, together with pll
Today i started fiddling with this file a bit and noticed that sometimes the gpio's wouldn't work, but after a hardware reset they would. Seeing the behaviour made me focus my efforts on the stm32 first.
Here's my main.c to be sure. It relies on the Standard Peripherals Library.
http://www.codepaste.net/jeb7uk
http://www.codepaste.net/jeb7uk
I'm thinking that the correct route would be the set the PLLSource to HSI, PLLMUL to 9x, usb prescaler /2. This way SYSCLK would be 48 mhz. Then AHB prescaler to 1, as well as APB2. APB1 prescaler would be 2 for 24 mhz PCLK1Thus far I haven't seen any change in the gpio behaviour (i can still debug the stm32 ok), but I'll try mucking with the clocks some more.
2011-03-29 09:53 AM
2011-03-29 11:11 AM
Yes, that was exactly the kind of simple thing that I hoped someone would point me to. It worked! Thanks a lot!
2011-03-29 02:56 PM
''The code i'm using works fine on the ''internal target'', the mcu on the board. Therefore i know that the gpio code is good.''
Lesson learned that ''working'' code is not necessarily ''correct'' code...?