cancel
Showing results for 
Search instead for 
Did you mean: 

First program not working .

kunal5959
Associate II
Posted on January 09, 2013 at 13:01

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--);

}

4 REPLIES 4
harshad
Associate II
Posted on January 09, 2013 at 13:26

Which IDE you are using? Are you able to download program correctly into MCU?

kunal5959
Associate II
Posted on January 09, 2013 at 13:31

I am Using IAR embedded Workbench C platform.. Ya downloading  shows no error.

kunal5959
Associate II
Posted on January 09, 2013 at 13:39

I am sorry i but i did not check properly .. the downloading is not occurring.

rob239955_stm1
Associate II
Posted on January 09, 2013 at 17:27

You might want to check your project settings - under Debugger, in the Setup tab, make sure the driver is set to your particular JTAG/debugger link type, and not to Simulator.

That one had me confused for a bit.