I am trying to advance my coding skills and venture into the world of high-end microcontrollers, coming mainly from a Java background (1 year of android developer as a daytime job plus a bit of C developing around Attiny in Atmel Studio) I fell in love with the abstraction provided by STM's HAL. I am aware that this is a sub-optimal solution from an optimization point of view but decided to go down this way because of how promisingly fast it looks.
I started from the very basics, turning on a LED but, after an evening of no luck I really need some help.
Here is my code, it is compiling fine, uploading fine but… nothing happens!
I'm using an STM32F4-Discovery board.
#include "stm32f4xx.h"
#include "stm32f4_discovery.h"
GPIO_InitTypeDef GPIO_InitStructure;
int main(void)
{
HAL_Init();
__GPIOD_CLK_ENABLE();
GPIO_InitStructure.Pin = GPIO_PIN_15;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_PULLUP;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
while (1) {
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_15, GPIO_PIN_SET);
}
}
Best Answer
Basically what @bitsmack suggested should look something like this:
I hope the comments are descriptive enough. This should work with an STM32F4 Discovery.
As for the other suggestion, STM32CubeMX, it gives a transparent way to configure your clocks (and other peripherals as well). You can check all the different buses and how they are clocked, switch between clock sources. You can see what for example what the
PLL_M
,PLL_N
,PLL_P
,PLL_Q
values exactly stand for. You can obtain this information from reference manual of the controller as well, but that would be a bit raw compared to this graphical representation.