Changing BAUD-rate in AN12218SW bootloader, non-zero reset values.

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

Changing BAUD-rate in AN12218SW bootloader, non-zero reset values.

ソリューションへジャンプ
1,338件の閲覧回数
roy_vanlierop
Contributor III

The AN12218SW uses the following code to change the baudrate:

 

	/* Calculate baud settings u32Baud = 19200*/
	pUART->BAUD |= LPUART_BAUD_OSR(15);
	u16Sbr = (u32SysClk/u32Baud)/16;
	pUART->BAUD |= LPUART_BAUD_SBR(u16Sbr);

 

This works for the default bootloader values as the calculated OSR/SBR value overlaps with the non-zero reset value. It is however not universal (at all!). 

roy_vanlierop_0-1621245572373.png

It would have been better if the AN12218SW would have used:

 

  /* Calculate baud settings*/
  pUART->BAUD = (pUART->BAUD & ~LPUART_BAUD_OSR_MASK) | LPUART_BAUD_OSR(15);
  u16Sbr = (u32SysClk/u32Baud)/16;
  pUART->BAUD = (pUART->BAUD & ~LPUART_BAUD_SBR_MASK) | LPUART_BAUD_SBR(u16Sbr);

 

It took me way to long to figure out the registers were non-zero. Especially OSR is very very wrong as it will always be 15 with the supplied code.  

0 件の賞賛
返信
1 解決策
1,320件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Thanks for sharing this, I will report it as well.

Thanks,

Lukas

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
1,321件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Thanks for sharing this, I will report it as well.

Thanks,

Lukas

0 件の賞賛
返信