Visar inlägg med etikett STM32. Visa alla inlägg
Visar inlägg med etikett STM32. Visa alla inlägg

måndag 10 augusti 2015

Clock setup for Olimex E407 using STM32CubeMX

Recently I got a reason to dig up my old Olimex E407 board and the RS232 shield I made for it (see earlier posts on this blog). This time though, I'm using Keil in Windows together with a ST Link V2. Getting the clocks and pll's right isn't an easy task, and certainly not a fun one, so I decided to give CubeMX and ST's HAL libraries a try.

The STM32CubeMX program (download it from ST.com) is a fairly new invention, and the libraries leave a lot to whish for still, so you should be careful with it. The libraries are still ful of bugs, but they are also getting a lot better rapidly.

Ok, first of course, download and install STM32CubeMX. If you want to launch it from Keil uVision, add the path to CubeMX to the system path environment variable. The start uVision5 and create a project for an STM407ZG.


Start CubeMX by clicking the "play" button right of the STM32Cube Framework (API).

Now, the Olimex E407 board is equipped with a 12 MHz external crystal clock and a 32.768 kHz external RTC crystal, so we have to enable those pins first.


Switch to the "Clock Configuration" tab and input 12 MHz as HSE input frequency and then make the following selections:
  1. Select HSE as PLL Soure Mux
  2. Set the /M divider to /7
  3. Set the *N multiplier to x196
  4. Set the /P divider to /2
  5. Select PLLSLK as System Clock Mux
  6. Set APB1 Prescaler to /4
  7. Set APB2 Prescaler to /2


Save it and select "Generate Code" from the Project menu.

When done, choose to close the CubeMX project and update the settings in uVision5.

A main.c file is generated for you that uses these new settings , ready to be filled in with your applicaiton source.

Good Luck

måndag 1 oktober 2012

DIY RS232 shield for the Olimex E407

My first hardware project with the E407 was to create an RS232 shield (they can be bought if you don't want to build it yourself). I used olimed own arduino proto shield. I happened to have a Maxim 232 driver circuit in my drawer, and also the five 1uF electrolytic capacitors needed to create this board.

First of all I discovered that the Olimex proto shield doesn't fit the board very well. I had to grind off one of the corners to make it fit with the power supply capacitors on the E407 board. A regular proto shield won't fit better... it seems like the capacitors aren't too well placed on the E407 board :-/

Since I am not very experienced in programming the STM32 processor I had to verify the construction with an AVR I had laying around and it seemed to work fine. I couldn't make it work with the E407 though.

I found out that the source I had downloaded from ST's site is designed for the Discovery board which has an 8 MHz external clock source. The E407 has a 12MHz clock. I had to generate a new system file with ST's excel tool. The patch can be found here.

I then compiled the example from Elias electronics blog, which seemed to work fine.

Good luck!