cancel
Showing results for 
Search instead for 
Did you mean: 

cannot operate out ports

ezrab
Associate II
Posted on September 28, 2010 at 18:28

hi

i am just in the begnnig of proraming the stm32 discovery.

i try to simply direct all of port c to output and put out ''1'' at all the ports so i wrote the following code:

#include ''stm32F10x.h''

int main(void)

{

 GPIOC->CRL=0x333333;

  GPIOC->CRH=0x333333;

  while(1)

  {

  GPIOC->ODR=0xffff;

  }

}

but it does not work.

why?

 

thanks for your help.
5 REPLIES 5
brazov22
Associate II
Posted on September 28, 2010 at 19:34

Hi,

I think you'd enable PORTC clock:

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);

have a look on examples:

http://www.st.com/stonline/products/support/micro/files/stm32f10x_stdperiph_lib.zip

brazov  

qili
Associate II
Posted on September 28, 2010 at 21:10

if you don't want to use library functions, the register to set is RCC_APB2ENR (I think, don't have a manual in front of me).

so something like

RCC_APB2ENR |=GPIO_GPIOCEN; (I may not have the names right so check the header file).

infoinfo968
Associate II
Posted on September 28, 2010 at 21:36

Virtually everything has to be 'turned on' by writing to RCC before it'll work. This got me too 🙂

qili
Associate II
Posted on September 28, 2010 at 23:52

most of the Cortex-Mx chips are like that, going back as far as the Luminary days.

the only exception that I know of is the LPC1768: the ports are clocked upon boot-up.

ezrab
Associate II
Posted on September 29, 2010 at 08:27

thanks .

it works!.