/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / only one led

Username:     
Password:     
             

Forum

# 1   2011-09-12 18:03:59 only one led

mike057
New member
Registered: 2010-12-16
Posts: 1

only one led

how to light a single LED? help please sad

Code:

#include "stm32f10x.h"



 #define LEDS_GPIO       (GPIOE)
 #define LED0_PIN   (GPIO_Pin_0)
 #define LED1_PIN   (GPIO_Pin_1)
 #define LED2_PIN   (GPIO_Pin_11)
 #define LED3_PIN   (GPIO_Pin_12)
 #define LEDS_PINS  (LED0_PIN|LED1_PIN|LED2_PIN|LED3_PIN)

 
  GPIO_InitTypeDef GPIO_IS;


volatile unsigned char toggle = 0;
int main( void )
{
 


while (1)
    {
    
        GPIO_IS.GPIO_Pin = LED0_PIN;
        GPIO_IS.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_IS.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_Init( LEDS_GPIO, &GPIO_IS);
    
    
    GPIO_Write( LEDS_GPIO, ( 1 ) );
    
    
    }

}

what's wrong?

Offline

 

# 2   2011-09-14 06:03:20 only one led

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: only one led

You must first start the clock on the peripheral you want to use, before the configuration.

In your case :
    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOE, ENABLE );

Note : it would be better to do the configuration only one time before the while (1)

Offline

 

# 3   2011-10-29 02:55:57 only one led

wenlong
New member
Registered: 2011-10-29
Posts: 1

Re: only one led

and use the reset register GPIOX_BRR(X=A,B,C..) then you can rest the coreesponding ODRx bit.

Offline

 

# 4   2012-05-31 08:22:07 only one led

ElvisUnknow
New member
Registered: 2012-05-31
Posts: 1

Re: only one led

As is does GPIO_Pin_7 mean pin 7 on the connector the AUDIO_I2S2_SCK port??? Is there a diagram or map for GPIO and USART that shows this?

How could I drive a LED from one of the ports on the connector?

led tube lighting
LED Spotlight
LED Downlight

Offline

 

Board footer