Porting to FEZ Cerb40 board

Posted on
  • Hi,

    I'm currently trying to port Espruino to the GHI Electronics FEZ CERB 40 board which is using a STM32F4. So I took the STM32F4DISCOVERY board configuration and compiled and flashed it to the board using the dfu-util. After I connected a serial line I have seen garbage on the terminal. It looks like I have a timing issue on my serial line so my current guess is that the PLL is not set up as expected. I looked closer to the schematics of the CERB40 and the STM32F4DISCOVERY and spotted that they are using a different system crystal. CERB40 uses 12 MHz instead of 8 MHz on the DISCOVERY. So I looked in the source and found the PLL_M define in targetlibs/stm32f4/lib/system_stm32f4xx.­c and changed it from 8 to 12 to get to the 168 MHz. So after a make clean and a recompile and flash I still get the garbage on the serial line. Can anybody give me a pointer what I might be missing here?

    Thanks in advance,


  • I'm not 100% sure I'm afraid - you're on the right track with targetlibs/stm32f4/lib/system_stm32f4xx.­c - try setting HSE_VALUE too in stm32f4xx.h (this could be done with a DEFINES+= in the Makefile).

    I guess if you looked at the serial port waveform with an Oscilloscope you might get an idea of how fast/slow it was running...

  • Hi Gordon,

    thanks for your support. I managed to compile Espruino for the FEZ Cerb 40. I changed the HSE_VALUE to 12000000 and the PLL_M to 12. Strangely I get a baud rate of ~14400. I would like to commit this support upstream. Any idea how the STM32F4DISCOVERY and the FEZ CERB40 can coexist since they use the same targetlib but with different value for PLL_M which is currently not using an if not defined statement like the HSE_VALUE (maybe change this to a if not defined and override the default of 8 from the Makefile?). Looking forward to my Espruino board.

    Thanks for your support


  • Hi,

    Yes, changing the code to support an #ifdef for PLL_M would be a great idea...

    Does USB Virtual Com port work on it? I think it's pretty important that you can get the baud rate down to 9600 though - as probably everything else is out as well (getTime, PLL, SPI, OneWire, etc) which makes it far less useful!

    It seems to me as if 14400/9600 = 1.5 - which is also the same as the change in PLL you're using: 12/8. Is it possible that PLL_M is not being changed everywhere (maybe just make clean?) and that means that the clock speed that Espruino thinks it is running at is wrong?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Porting to FEZ Cerb40 board

Posted by Avatar for Frickler @Frickler