USART2

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
pagano.paganino
Posts: 89
Joined: Fri Sep 11, 2015 10:47 pm
Location: Italy

Re: USART2

Post by pagano.paganino » Sat Sep 19, 2015 8:54 am

Hi Dave,
i have tried to put down the cpu frequence from 168MHz to 160MHz but the result isn't 160MHz:

Code: Select all

Micro Python v1.4.5-99-g4e7bde8-dirty on 2015-09-19; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> pyb.freq()
(168000000, 168000000, 42000000, 84000000)
>>> pyb.freq(160000000)
>>> pyb.freq()
(144000000, 144000000, 36000000, 72000000)
>>>
Thanks,
Francesco

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: USART2

Post by pythoncoder » Sun Sep 20, 2015 11:01 am

I'm not sure what @dhylands had in mind here, but from the manual:
Note that not all values are supported and the largest supported frequency not greater than the given value will be selected.

Supported sysclk frequencies are (in MHz): 8, 16, 24, 30, 32, 36, 40, 42, 48, 54, 56, 60, 64, 72, 84, 96, 108, 120, 144, 168.
which explains your observation.
Peter Hinch
Index to my micropython libraries.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: USART2

Post by dhylands » Sun Sep 20, 2015 5:14 pm

I neglected to look at the datasheet and made some assumptions.

Looking at the datasheet, it says that the SCLK frequency can be set frok fCK/2 to fCK/62 where fCK is the peripheral input clock, which I believe is 42 MHz. So since you have to divide by an even number, I don't think you can get 4 MHz. You can get 4.2 MHz or you can get 3.5 MHz.

In order to get exactly 4 MHz, the CPU frequency needs to be an integer multiple of 16 MHz. It looks like 96 MHz is the largest frequency which is a multiple of 16.

Post Reply