W
W
wolk2016-12-03 01:12:54
STM
wolk, 2016-12-03 01:12:54

How to light a diode on STM32?

I have an STM32VLD board. For programming I use CooCox 1.7.8.
Googling and sorting through a bunch of examples, I did not understand how to light the idle built-in LED.
Please tell me what am I doing wrong?

#include<stm32f10x_rcc.h>
#include<stm32f10x_gpio.h>
#include "stm32f10x.h"
#include "stm32f10x_conf.h"


GPIO_InitTypeDef GPIO_InitStructure;

volatile int main(void)
{
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_8 | GPIO_Pin_9;
  GPIO_Init(GPIOC, &GPIO_InitStructure);

  GPIO_WriteBit(GPIOC,GPIO_Pin_9,Bit_SET);
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maria Maltseva, 2016-12-05
@Moriam

In the iar environment, your code works and the LED on C9 lights up.
As for the code - write an infinite loop at the end - while (1) {} - so that the controller does not complete its work

1
123459, 2016-12-05
@123459

we.easyelectronics.ru/Frolls/moya-ochered-morgat-s...
easyelectronics.ru/arm-uchebnyj-kurs-porty-gpio.html
www.st.com/content/st_com/en/products/evaluation-t ...
we.easyelectronics.ru/thodnev/prakticheskiy-kurs-s...
we.easyelectronics.ru/STM32/prakticheskiy-kurs-stm...

F
freeExec, 2016-12-05
@freeExec

I can assume that at the beginning of creating projects, you did not choose your chip correctly, and the defines that adjust the frequencies depend on this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question