The result will be approximately 1 blinks per second: It will toggle the led, not caring what the previous state was, and then wait for 500 ms. The approach is simple and easily understood. Using Stm32CubeIde and it's HAL libraries, the main loop will look something like: In this approach, the led is simply toggled in the main loop of the program, with an appropriate delay. This approach, while quite misguided, is often seen in examples, particularly Arduino based ones. This is the frequency at which the timers will operate (in this case 72 MHz - remember this value for later examples). Also important to notice is the value of the APB1 Timer Clocks. The important values here is the value of the external crystal (in this case 8 MHz), the value of HCLK, which is the frequency the processor will run at. Second step is to configure the CPU to enable the external crystal:įinal step is to configure the various clocks: First step I configure the Serial Wire debug (including the trace): When starting a new project in Stm32CubeIde, I generally go through some common settings. Stm32CubeMx is used to "configure" the processor. These are discussed in the following sections.įor these examples, I will be using ST's Stm32CubeIde, which includes Stm32CubeMx. Using the STM32 HAL from ST there are a number of different ways to blink a LED.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |