LPC812 USART and Fractional Baud setting - 12mhz IRC_osc to 115200 baud needed

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC812 USART and Fractional Baud setting - 12mhz IRC_osc to 115200 baud needed

ソリューションへジャンプ
4,386件の閲覧回数
jmullen_condose
Contributor III

I am moving a design from LPC804 (15mhz int osc) to LPC812, which has a 12mhz internal osc. The code for the UART baud generation fails at

assert((((srcClock_Hz >> 4U) / brgval) - baudrate_Bps) < ((baudrate_Bps / 100U) * 3U));

Indeed, looks like about an 8% error to 115200 and the comms are garbage of course if I continue with a brgval = 6 (-1) =  106175 baud

I see there is FRG that can be set!
I have not encountered (or needed) fractional rate registers before, and after a couple hours of research I am still at a loss of how to implement this (long day? not enough coffee? crossed eyes?!), therefore I am asking if anyone already has experience in the directly setting up of the LPC812's registers for my situation - which is 12mhz internal osc running the chip (battery application) and needing 115200 (to a LoRa module).

I know the solution is about 3 magical lines of code for setting the baud and fractional registers correctly, but I cannot figure them out while simultaneously retaining my hair.... Please assist.

Cheers! -jeff-

 

0 件の賞賛
返信
1 解決策
4,380件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

If you want to get 115200 baud rate, the USART driving clock must be 115200*16=1.8432MHz.

As you know that the Fractional Rate Generator can get a ratio between 1 and 2.

If the IRC is 12MHz, you set up the UARTCLKDIV,=12, the input clock frequency of Fractional Rate Generator module will be 1MHz.

Set up the UARTFRGMULT=215, set up the UARTFRGDIV=255, using the equation

the Fractional Rate Generator ratio will be (1+MULT/DIV)=1+215/256=1.84

so the usart clock frequency will be 1MHz*1.84=1.84mHz. If you set the uart buad rate register BRG=1, you will get 115200 baud rate.

Pls have a try

Hope it can help you

BR

XiangJun Rong

 

xiangjun_rong_0-1646883598057.png

 

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
4,381件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

If you want to get 115200 baud rate, the USART driving clock must be 115200*16=1.8432MHz.

As you know that the Fractional Rate Generator can get a ratio between 1 and 2.

If the IRC is 12MHz, you set up the UARTCLKDIV,=12, the input clock frequency of Fractional Rate Generator module will be 1MHz.

Set up the UARTFRGMULT=215, set up the UARTFRGDIV=255, using the equation

the Fractional Rate Generator ratio will be (1+MULT/DIV)=1+215/256=1.84

so the usart clock frequency will be 1MHz*1.84=1.84mHz. If you set the uart buad rate register BRG=1, you will get 115200 baud rate.

Pls have a try

Hope it can help you

BR

XiangJun Rong

 

xiangjun_rong_0-1646883598057.png

 

0 件の賞賛
返信