AnsweredAssumed Answered

Code crashes when SCI0CR2_TE i set

Question asked by Abdoulah Sangare on May 25, 2018
Latest reply on May 29, 2018 by lama

I have a function to initialize the UART port. When I run the code in debug mode in CodeWarrior, it always crashes after the 'SCI0CR2_TE = 1;' line is executed. I ended up in the '4A4D' memory region and the debugger says an unknown event has occurred. Can anyone help with this? What may be the problem?

 

unsigned char InitializeUART ( void )
{
  // THE UART WILL BE CONFIGURED FOR ...
  SCI0BDL = 0x0D; /*Configure baud rate at 19200 bps with*/
  SCI0BDH = 0x00; /*an SCI clock modulo of 4MHz*/

  SCI0CR1 = 0x00; /*8 data bits, no parity*/

  SCI0CR2_RE = 1;
  SCI0CR2_TE = 1;
  SCI0CR2_RIE = 1;


  if (SCI0SR1 & 0x80){ /*Poll TDRE flag*/
  return ERROR_OK; /*TDRE set, return OK*/
  } else {
    return ERROR_ERROR; /*TDRE clear, return ERROR*/
  }

}

Outcomes