Blinky2: 

 

Reference Documents:


    STM32F4DISCOVERY high-performance discovery board data brief


    STM32F4DISCOVERY peripherals firmware examples (AN3983)


    STM32F40x reference manual (RM0090)


    STM32F405xx STM32F407xx datasheet 

 

The above documents are all available @ www.st.com/stm32f4-discovery

 

     Once again, for the sake of repetition, and for the opportunity to check out the differences between The Stm32 M3 and M4 versions; 

 

let's rewrite the short and simple M3 Blinky native code program in order to flash the 4 User Leds on the STM32F4DISCOVERY board.

 

After declaring a few equates once more, the routine starts by firstly initialising the clock for GPIOD and setting Pins 15,14,13,12 to general purpose

 

Push-Pull outputs with a bandwidth @ 2 Mhz. Unlike the AVR/PIC the Arm Ports are synchronous and have their own clock!!!

 

    The four onboard leds on the STM32F4DISCOVERY are set to Hi for 250mS and then to Low for 2 Seconds using the BitSet/Reset Register on GPIOD

 

The program then loops back to the label "Main" and the routine repeats itself in an endless loop. Both delays are handled purely in software as for now 

 

.... (Fpu, Rng, Dacs, etc. are due later, I promise :-) Use the freely available manuals on the Stm website above to understand what's going on and 

 

all the best to ex-AVR programmers, who, just like I was, must be, at first, bewildered by the apparent complexities of the extremely powerful 

 

STM32F4VGT6 chip. We are still using the phat Keil Mdk-Arm compiler Lite version, which allows us to compile and link up to 32Kbytes of code free. 

 

It has a built in optimising compiler/simulator and to enable us to use these super tools, I've decided, for now, to avail of  the built-in loader/linker to initialise 

 

and call the assembly program. This comes with a fixed "C" overhead of 688 bytes but with 32,000 bytes remaining, I still think we can afford it!

 

Sometime soon, I hope, a bare metal version in 100% native code, will be winging its way to this website :-)

 

    The differences between the M3 and the M4 are far outweighed by the similarities, which unite them. Apart from the massive speed increase

 

from 72 to 168 Mhz, the much larger memories, and  the addition of many new peripherals, the "feeling" remains more or less the same. 

 

The GPIO structure has lost the Port Bit Reset Register (GPIOx_BRR), but I find the new structure to be more logical and intuitive, and I'm really looking 

 

forward to investigating the deeper level mysteries of the hardware even further.

 

    Setting up the project using the Keil uVision Ide remains relatively straight forward, if at first a bit time consuming; but once done, it's amazing 

 

how easy it gets with a little practice, and help and encouragement is always to be found by sending me an Email ;-)

 

" I seem to be a verb! " Bucky Fuller.

 

    Download