cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 - USART1 external clock?

nick239955
Associate II
Posted on September 05, 2012 at 03:07

Hi!

Is there a way to clock (only) USART1 using a (variable) external clock of 1 to 12 Mhz?

Also, is there a way to clock USART2 using another clock source than system?

Thank you!
6 REPLIES 6
Posted on September 05, 2012 at 05:01

Not so much.

How about slave mode SPI?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nick239955
Associate II
Posted on September 05, 2012 at 11:32

No, SPI won't do... 

I've been digging throught the datasheet, it seems USART1 can be clocked with a LSE clock of 32-1000kHz, are these numbers correct? 

Thank you!

nick239955
Associate II
Posted on September 05, 2012 at 16:16

If the LSE has to be 32.768 what I'm trying to do won't work, but if it will work up to 1000kHz then it will... so I'm not sure how to interpret this aspect.

Posted on September 05, 2012 at 18:46

You'd need to experiment with the 1MHz LSE, no doubt it will increase current draw in sleep/stop

You should be able to accommodate it on the RTC front by programming the prescaler registers RTC_PRER at 100 and 10000 respectively.

I'd need to review the notes from the seminar, but I'm under the impression it could run the USART from HSI while in low power modes, ie keeping a clock ticking that would otherwise be disabled. My recollection was there was some inferred behaviour, but the details were sketchy when pressed for specifics. Would strongly recommend getting a F0-Discovery board and validating oneself.

I think HSI would be preferable in order to get a reasonable selection of baud rates, but I'm not sure what your expectations/requirements are here.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nick239955
Associate II
Posted on September 05, 2012 at 20:48

Clive,

My main concern is whether the USART will operate with the LSE clock at ONLY 32.768 kHz 

- or -

it is actually possible to use anything between 32.768 and, let's say 500kHz.

If the latter is correct as per the second reference within the specs, then I can use a divider to make sure our CLK line won't cause trouble by overlocking the USART if/when the frequency goes significantly over 1Mhz.

Posted on September 05, 2012 at 21:09

It will operate at an appalling low baud rate, say 4096 baud with oversampling by 8. That looked to be of no use for any applications I had. Plus presumably you'd need to come out of any sleep state quick enough to service the holding register before it overflowed.

The F0-Discovery comes with unpopulated pads to experiment with external oscillators. This is definitely an area where you'd need to test the practicality of the implementation.

Other forum users might have specific experience, but it's relatively light on such users, and the area being probed rather niche.

My interpretation of the documentation suggests you can use different LSE crystals, you're going to need 6pF ones, and you might have to play with R and C values to accommodate the part chosen to permit it to start/oscillate as desired.

The RTC can handle different rates based on the two stage prescaler.

The USART can handle different clock sources, and baud rates. These can be switched on the fly, but are not intrinsically glitch free. You might be able to mitigate this somewhat, but would need to use a protocol that could tolerate byte loss.

The inferred operation was that HSI would stay on if it was the selected source, but it's not something I validated. This differs from the STM32 series parts I've used.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..