Code crashes when SCI0CR2_TE i set

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

Code crashes when SCI0CR2_TE i set

525 Views
abdoulah
Contributor I

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*/
  }

}

0 Kudos
1 Reply

284 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

Since you have not provided detailed info I only focus at the line:

SCI0CR2_RIE = 1;

You enable interrupt locally, I am not able to check whether you enabled it also globally and whether corresponding routine exists.

So I see the issue you enable interrupt, and it is launched without existing interrupt subroutine, or there is wrong placement of subroutine.

I would like to suggest to add, in the future, the MCU type, BUSCLK, the best is to attach short (very short) example project (in CodeWarrior...to be easily checked by NXP support team)  which highlights the issue.

It is good to see BUSCLK setup, oscillator clock, interrupts setup,....in the case of such  issues.

It is possible I have or I published here UART examples which could hep you but it is not possible to direct you to them if there is no info about the MCU type.

Best regards,

Ladislav

0 Kudos