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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
978 Views
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 Kudos
Reply
1 Solution
960 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

Thanks,

Lukas

View solution in original post

0 Kudos
Reply
1 Reply
961 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

Thanks,

Lukas

0 Kudos
Reply