AnsweredAssumed Answered

First program not working .

Question asked by parthiban.kunal on Jan 9, 2013
Latest reply on Jan 9, 2013 by neff.rob
I am trying to falsh a example program through a STM32 discovery debugger/programmer on an external STM32 chip. all the connections are right and done according to the instructions written in the Datasheet of STM discovery. Even Build was executed without any error .I have n clue now why i cannot see the LED blinking on PORTA.3 and PORTB.0. The code i have used is as shown below':-


#include "stm32f10x_conf.h"


/* led connected to a gpio pin */
#define LED1_PIN    GPIO_Pin_0
#define LED1_PORT   GPIOB


#define LED3_PIN    GPIO_Pin_3
#define LED3_PORT   GPIOA




/* user functions */
void delay(unsigned long count);


  int main()
{
    GPIO_InitTypeDef GPIO_InitStructure;




    /* Enable GPIOx Clock */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
    
    /* Setup SysTick Timer for 0.1 msec interrupts  */
    if (SysTick_Config(SystemCoreClock / 10000))  // old 1000
    { 
      /* Capture error */ 
      while (1);
    }


    /* enable clock on GPIOB peripheral */
    //RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOA, ENABLE);                          




    /* set pin output mode */
    GPIO_InitStructure.GPIO_Pin = LED1_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(LED1_PORT, &GPIO_InitStructure);
    //LED 2


    //LED 3
    GPIO_InitStructure.GPIO_Pin = LED3_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(LED3_PORT, &GPIO_InitStructure);
    //LED 4
   
    while(1)
    {
        GPIO_SetBits(LED1_PORT, LED1_PIN);  // set pin high
        delay(2000000);
        GPIO_ResetBits(LED1_PORT, LED1_PIN);    // set pin low
        delay(2000000);


 


        GPIO_SetBits(LED3_PORT, LED3_PIN);  // set pin high
        delay(2000000);
        GPIO_ResetBits(LED3_PORT, LED3_PIN);    // set pin low
        delay(2000000);


    
    }
    //return 0;
}






void delay(unsigned long count)
{
    while(count--);
}





Outcomes