cancel
Showing results for 
Search instead for 
Did you mean: 

Port I/O

agilmore19
Associate II
Posted on October 16, 2010 at 21:34

Hi, I'm new to the forum and the discovery board. Got it working with the test routines. Is it possible to switch a led, say LED5, connected to PC11, on and off using the routines in STM32_Discovery. If so how do I declare the led port?

Many thanks

Alastair

2 REPLIES 2
Posted on October 17, 2010 at 04:40

Hi, I'm new to the forum and the discovery board. Got it working with the test routines. Is it possible to switch a led, say LED5, connected to PC11, on and off using the routines in STM32_Discovery. If so how do I declare the led port?

 

Enumerate additional GPIO's in STM32vldiscovery.c/h, or just program them directly.

void GPIOSetup(void)

{

  GPIO_InitTypeDef  GPIO_InitStructure;

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);

  /* Configure the PC.11 pin */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_Init(GPIOC, &GPIO_InitStructure);

}

void GPIOLed(int i)

{

  if (i)

    GPIOC->BSRR = GPIO_Pin_11; // PC.11 On

  else

    GPIOC->BRR = GPIO_Pin_11; // PC.11 Off

}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
agilmore19
Associate II
Posted on October 18, 2010 at 10:26

Many thanks, that worked a treat. I'd rather try and make use of the already written functions rather than try to rewrite them myself, particularly since I am on a learning curve.

Alastair