cancel
Showing results for 
Search instead for 
Did you mean: 

First simple Keil GPIO not working! HELP PLEASE!

tre2020067
Associate II
Posted on August 30, 2011 at 07:12

So i took the Stm32 gpio.zip project and changed the configuration to the bank i wanted to use and changed the main to a very simple bit switch. can someone tell me why it wont work?

#include <stm32f10x_lib.h>                        // STM32F10x Library Definitions

#include ''STM32_Init.h''                           // STM32 Initialization

/*----------------------------------------------------------------------------

  MAIN function

 *----------------------------------------------------------------------------*/

int main (void) {

  stm32_Init ();                                  // STM32 setup

  while (1) {                                     // Loop forever

    /* Set PE0 */

    GPIOE->ODR |= (1 << 5);

  } // end while

} // end main

                                                   
9 REPLIES 9
Posted on August 30, 2011 at 07:57

Can't suggest anything for the initialization code as it's not presented.

You appear to be setting PE5

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tre2020067
Associate II
Posted on August 30, 2011 at 08:25

i used the keil configuration wizard. i set the gpioe to pin5 out put. 0690X00000604yoQAA.png 0690X00000604ysQAA.png 0690X00000604yxQAA.png

Posted on August 30, 2011 at 13:22

So you're pretty much reliant on the code generator/wizard to produce the correct code. What part/board are you using? When you debug or single step the code can you see it altering peripheral registers?

  while (1) {                                     // Loop forever

    /* Toggle PE5 */

    GPIOE->ODR ^= (1 << 5);

   }

For it to work the GPIOE clocks need to have been enabled, and the pins configured. You could dig through the generated code to confirm that, or look at a peripheral window in the debugger.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tre2020067
Associate II
Posted on August 30, 2011 at 18:38

the board im using

http://www.ebay.com/itm/ARM-Cortex-M3-STM32F103VET6-Mini-Development-Board-/190550067511?pt=LH_DefaultDomain_0&hash=item2c5dab4937

its a no name board from china. a stm32f103fvet6.

when compile i get a warning:

Gpio.c(35): warning:  #1-D: last line of file ends without a newline

when i debug:

http://i55.tinypic.com/2ziu810.jpg

the GPIOE clock is disabled. so i check the APB2 register and see that the clock is disabled here too. so i enabled the peripheral clock for GPIOE and notice that GPIOE is set to all inputs. i switch PE.5 to output and it works.

but when i download it to the board it doesnt do anything.

http://www.ebay.com/itm/ARM-Cortex-M3-STM32F103VET6-Mini-Development-Board-/190550067511?pt=LH_DefaultDomain_0&hash=item2c5dab4937

raptorhal2
Lead
Posted on August 30, 2011 at 20:24

I am puzzled by the wizard screens. None of the GPIOE pins can function as analog inputs. Does the wizard assume the user knows best ?

If the wizard can produce a C code listing, look at that and, if you can't spot the error, post it for review.

Cheers, Hal

Posted on August 30, 2011 at 22:23

The debug screen suggests the PE5 pin is configured as open-drain, you'd need a pull-up for it to go high.

Make sure it's push-pull, and instead of just repeatedly trying to set PE5 high, you should perhaps toggle it so you can observe it with an oscilloscope.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tre2020067
Associate II
Posted on August 31, 2011 at 04:50

can you tell me how to manually enable apb2 gpioe in KEIL? i dont think the config wizard is doing anything.

tre2020067
Associate II
Posted on August 31, 2011 at 04:51

can you tell me how to manually enable apb2 gpioe in KEIL? i dont think the config wizard is doing anything.

tre2020067
Associate II
Posted on September 10, 2011 at 01:58

UPDATE!!!

 i just wanted to let u know i solved the problem by switching to IAR workbench  :))