AnsweredAssumed Answered

STM32L_Discovery Blinking LEDS

Question asked by moore.chuck on Aug 21, 2013
Latest reply on Aug 21, 2013 by Clive One
I have an STM32L-Discovery Board, I found this program compiled it and loaded it on my board but nothing happens.  What am I miising..  Thanks in Advanced. 

CM.

GPIO_InitTypeDef (GPIO_InitStructure);
     


int main() {
     GPIO_InitTypeDef ledInit;
     long i = 0;


      // enable the GPIOB peripheral
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
     
     
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; // 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //  push-pull output 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; 
GPIO_Init (GPIOB, & GPIO_InitStructure); // B port 


GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; //
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //  push-pull output 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; 
GPIO_Init (GPIOB, & GPIO_InitStructure); // B port 
     
       // configure pins 6 and 7 as GPIO output
     ledInit.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_6;
     ledInit.GPIO_Mode = GPIO_Mode_OUT;
       // initialize the peripheral
     GPIO_Init(GPIOB, &ledInit);     
       // turn pins 6 and 7 on
     GPIO_SetBits(GPIOB, GPIO_Pin_7 | GPIO_Pin_6);


       // loop forever
     for (;;) {
                // toggle pins 6 and 7
                
   
                          GPIOB->BSRRL = GPIO_Pin_7; 
              GPIOB->BSRRH = GPIO_Pin_7;
                 GPIOB->BSRRL = GPIO_Pin_6;
           GPIOB->BSRRH = GPIO_Pin_6;
          
          // waste time
             for (i=0; i<25000; i++);
     
     return 0;
       }

Outcomes