Skip to main content
agilmore19
Associate II
Oct 16, 2010 7:34 PM UTC
Question

Port I/O

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

    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    Oct 17, 2010 2:40 AM UTC
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    agilmore19
    Associate II
    Oct 18, 2010 8:26 AM UTC
    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