Mikro2 Clicker 2 (F407 based) - UART clock issue

Posted on
  • Hi,

    I have a strange bug when I compile Espruino for the Mikro2 clicker 2 (see here for more information about this board). It is based on the STM32F407VGT6, the same MCU that is on the F4discovery board. Thus I started with the STM32F4DISCOVERY.py file to modify the pin names, and I change the prescalers in the system_stm32f4xx.c file located in targetlibs/stm32f4/lib, because the quartz on the mikro2 board is a 25 MHz quartz (it's a 8MHz quartz on the F4DISCO board).

    Everything compiles well and I'm indeed able to run Espruino on the clicker2 board through the USB port. My problem appears when I try to connect a UART module: the effective baud rate I get is not the one I set, it is multipled by a factor 3.125 ?!? So I have to set the baudrate to 18432 to have it at 57600.

     Serial3.setup(18432, { tx:D8, rx:D9 });
    

    Knowing that 3.125 = 25/8, I guess this issue is related to the fact that there is an "8" MHz lost somewhere in the Espruino files to compile.

    My question is then: is there another file where I have to change the quartz frequency, in addition to the system_stm32f4xx.c file ?

    Thanks for your help :)

  • I'd have said changing system_stm32f4xx.c is what you need - not sure why it wouldn't be taking effect.

    You could have a play with http://www.espruino.com/Reference#l_E_setClock - it'll allow you to play with prescalers on the fly so at least you can test and see if it's doing the right thing

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

Mikro2 Clicker 2 (F407 based) - UART clock issue

Posted by Avatar for benoit @benoit

Actions