baud rate generated wrong speed

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

baud rate generated wrong speed

727 Views
christianlara
Contributor III

i´m creating a new project  to the M52233DEMO board using processor expert, using component library AsynchroSerial config to 19200 bauds,

components:

Component: Cpu of type MCF52233CAL60

Description: Freescale ColdFire family: MCF52233_112_LQFP: clock-source:25Mhz,

for(;;){

   AS1_SendChar('a');

  }

 

sending a simple char 'a' i get  trash always,  and i get error if i select MCF52233CAF60  instead MCF52233CAL60, error is illegal instruccion halt.

why is wrong the speed always,

please help

Labels (1)
2 Replies

598 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Christian,

There is an errata that affects the Clock control high register (CCHR), causing the writes to the clock control high register to have no effect, even though reading this register shows it has been updated.

You can find more information on this document:

http://cache.freescale.com/files/32bit/doc/errata/MCF52235DE.pdf

I would recommend you to try using the following code:

replace the system clock initialization code on the Cpu.c file with the following:

/* System clock initialization */

// Clock source is 25.0000 MHz external crystal

// Clock mode: Normal PLL mode

// Processor/Bus clock frequency = 60.00 MHz

// Loss of clock detection disabled

// Reset on loss of lock disabled

// Divide 25.0000 MHz clock to get 5.00 MHz PLL input clock

// Set RFD+1 to avoid frequency overshoot and wait for PLL to lock

setReg16(SYNCR, 0x4103U);            /* Set the SYNCR register */

while (!(SYNSR & SYNSR_LOCK_BITMASK)){} /* Wait until the PLL is locked. */

// Set desired RFD=0 and MFD=4 and wait for PLL to lock

setReg16(SYNCR, 0x4003U);

while (!(SYNSR & SYNSR_LOCK_BITMASK)){} /* Wait until the PLL is locked. */

/* RTCDR: RTCDF=0x007A11FF */

setReg16(SYNCR, 0x4007U);// Switch to using PLL

and change the AS1_Init code on the AS1.c file with the following:

void AS1_Init(void)

{

  SerFlag = 0x00;                      /* Reset flags */

  /* UCR0: ??=0,MISC=3,TC=0,RC=0 */

  setReg8(UCR0, 0x30U);                /* Reset UART transmitter */

  /* UCR0: ??=0,MISC=2,TC=0,RC=0 */

  setReg8(UCR0, 0x20U);                /* Reset UART receiver */

  /* UMR10: RXRTS=0,RXIRQ=0,ERR=0,PM=2,PT=0,BC=3 */

  setReg8(UMR10, 0x13U);               /*  Set the UMR1 register */

  /* UMR20: CM=0,TXRTS=0,TXCTS=0,SB=7 */

  setReg8(UMR20, 0x07U);               /*  Set the UMR2 register */

  /* UCSR0: RCS=0x0D,TCS=0x0D */

  setReg8(UCSR0, 0xDDU);               

  /* UBG10: Divider_MSB=0 */

  setReg8(UBG10, 0x00U);               

  /* UBG20: Divider_LSB=0x61 */

  setReg8(UBG20, 0x61U);               

  HWEnDi();                            /* Enable/disable device according to status flags */

}

With this you should get the desired 19200 baud rate.

To prevent Processor Expert of overwriting the above changes to the code you need to disable the code generation of those components, here is a post created by a colleague that explains how to do this:

Disable my Code Generation | MCU on Eclipse

Hope it helps!

Best Regards,

Carlos Mendoza

Technical Support Engineer

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

598 Views
christianlara
Contributor III

english:

I do not know how to replay in the comunity web page, is interesting your answer, i will use it in case the problem continue, i resolve it, adding a component named timer- output, when the baud rate- desconfigure again, i remove the component timer-out. and the baud rate- is ok. again. thanks.

spanish:

No se como contestar tu respuesta en la pagina de la pregunta, pero me parece interesante tu respuesta aunque un poco mas laboriosa y yo tengo poco tiempo para el desarrollo. Lo solucione agregando un componente en el processor expert llamado timer-out, y el baud-rate y el reloj principal del sistema se corrigen, cuando se desconfigura otra vez por moverle al processor expert solo le quitamos este componente y se soluciona el problema del baud-rate sin necesidad de meterse tanto en la arquitectura. muchas gracias por tu ayuda.