Re: [libopenstm32-devel] usart_set_baudrate(...)
Status: Inactive
Brought to you by:
uh1763
From: Gareth M. <ga...@bl...> - 2011-03-13 00:53:06
|
On Thu, Mar 10, 2011 at 2:34 AM, Nico von Geyso <Nic...@fu...> wrote: > I had some problems with the usart_set_baudrate() function and so I took > a deeper look how it works. > The baud rade generation for stm32 is described in the section > "Fractional baud rate generation" in RM0008 Reference manual, Page 747. If I read it correctly, all the talk in the manual makes it sound fancy and complicated, but the simple division calculates the correct value. > For the stm-h107 development the current implementation works fine for > usart 2,3 but not for usart1. > Usart1 has a different clock source (PCLK2, 72Mhz) and so you have to > divide the baud parameter (for usart_set_baudrate(...)) by two to get > the correct values. > As it is hard to get the current pclk1 or pclk2 values, wouldn't it be > better if there is a function like the following: > > void usart_set_baudrate(u32 clock, u32 usart, u32 baud); //set the > clock manually I think this is the most obvious way to do it. I would swap the clock and usart parameters though. Regards, Gareth -- Black Sphere Technologies Ltd. Web: www.blacksphere.co.nz Mobile: +64 27 777 2182 Tel: +64 9 478 8885 Skype: gareth.mcmullin LinkedIn: http://nz.linkedin.com/in/gsmcmullin |