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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
1,339 次查看
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,321 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

Thanks,

Lukas

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,322 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

Thanks,

Lukas

0 项奖励
回复