MPC5606S UART Interrupt problem

cancel
Showing results for 
Search instead for 
Did you mean: 

MPC5606S UART Interrupt problem

592 Views
skysword
Contributor II

Hi all,

       I am trying to use MPC5606S UART interrupt function, but can not enter the interrupt service program.

It can not enter the interrupt function to send(  void UART1_TransmitComplete(void)) and receive(void UART1_ReceiveComplete(void)) interrupt function, attachment is my project, please help me to see where the problem?

 

Here's my code:

#include "MPC5606S.h"
#include "IntcInterrupts.h"

int counterTX = 0;
int counterRX = 0;
char receiveBuffer[20];

void initModesAndClock(void) ;
void disableWatchdog(void);
void initPeriClkGen(void) ;
void UART1_Init(void);
void UART1_SendData(char data);
void UART1_TransmitComplete(void);
void UART1_ReceiveComplete(void);

void initModesAndClock(void)
{
//h04_GpioInit();
ME.MER.R = 0x0000001D; /* Enable DRUN, RUN0, SAFE, RESET modes */
/* Initialize PLL before turning it on: */
CGM.FMPLL[0].CR.R = 0x02400100; /* 8 MHz xtal: Set PLL0 to 64 MHz */
ME.RUN[0].R = 0x001F0074; /* RUN0 cfg: 16MHzIRCON,OSC0ON,PLL0ON,syclk=PLL0 */
ME.RUNPC[1].R = 0x00000010; /* Peri. Cfg. 1 settings: only run in RUN0 mode */
//ME.PCTL[32].R = 0x01; /* MPC56xxB/P/S ADC 0: select ME.RUNPC[1] */
ME.PCTL[68].R = 0x01; /* MPC56xxB/S SIU: select ME.RUNPC[1] */
ME.PCTL[49].R = 0x01; /* MPC56xxB/P/S FLEX1 : select ME.RUNPC[1] */
/* Mode Transition to enter RUN0 mode: */
ME.MCTL.R = 0x40005AF0; /* Enter RUN0 Mode & Key */
ME.MCTL.R = 0x4000A50F; /* Enter RUN0 Mode & Inverted Key */
while (ME.GS.B.S_MTRANS) {} /* Wait for mode transition to complete */
/* Note: could wait here using timer and/or I_TC IRQ */
while(ME.GS.B.S_CURRENTMODE != 4) {} /* Verify RUN0 is the current mode */
}

void disableWatchdog(void)
{
SWT.SR.R = 0x0000c520; /* Write keys to clear soft lock bit */
SWT.SR.R = 0x0000d928;
SWT.CR.R = 0x8000010A; /* Clear watchdog enable (WEN) */
}

void initPeriClkGen(void)
{
CGM.SC_DC[0].R = 0x80;
CGM.SC_DC[1].R = 0x80;
CGM.SC_DC[2].R = 0x80;
}

void UART1_Init(void)
{
volatile int i = 0;

LINFLEX_1.LINCR1.B.INIT = 1;
LINFLEX_1.LINCR1.B.SLEEP = 0;

LINFLEX_1.LINIBRR.R = 0x000001A0; //baud rate 9600b/s (fsys 64MHz)
LINFLEX_1.LINFBRR.R = 0x0000000B;

LINFLEX_1.UARTCR.B.UART = 1; //enable UART mode
LINFLEX_1.UARTCR.B.WL = 1; //set 8-bit data

LINFLEX_1.UARTCR.B.TXEN = 1; //enable transmitter
LINFLEX_1.UARTCR.B.TDFL = 0b00; //set transmitter buffer (1)
LINFLEX_1.LINIER.B.DTIE = 1; //Transmit interrupt enable

LINFLEX_1.UARTCR.B.RXEN = 1; //enable transmitter
LINFLEX_1.UARTCR.B.RDFL = 0b00; //set transmitter buffer (1)

LINFLEX_1.LINIER.B.DRIE = 1; //Receive interrupt enable

LINFLEX_1.LINCR1.B.INIT = 0; //disable init mode
for(i ; i < 5000; i++) //wait fo apply settings
{

}
}

 


void UART1_SendData(char data)
{
LINFLEX_1.BDRL.B.DATA0 = data; //send data
}

void UART1_TransmitComplete(void)
{
LINFLEX_1.UARTSR.R = 0x00000002; //clear interrupt flag

if(counterTX < 20) //check if less then 20 char was sent
{
UART1_SendData((char)counterTX); //send next data after received
counterTX++;
}
}

 


void UART1_ReceiveComplete(void)
{
LINFLEX_1.UARTSR.R = 0x00000004; //clear interrupt flag

receiveBuffer[counterRX] = LINFLEX_1.BDRM.B.DATA4; //copy received data to receiveBuffer

counterRX++;
}


int main(void) {
volatile int i = 0,j=0;

initModesAndClock(); /* Initialize mode entries and system clock */
disableWatchdog(); /* Disable watchdog */
initPeriClkGen(); /* Initialize peripheral clock generation for DSPIs */

UART1_Init();
SIU.PCR[29].R = 0x0600; //LIN1 TX
SIU.PCR[28].R = 0x0100; //LIN1 RX


INTC_InstallINTCInterruptHandler(UART1_ReceiveComplete,99,15);
INTC_InstallINTCInterruptHandler(UART1_TransmitComplete,100,14);

INTC.CPR.R = 0;


UART1_SendData((char)counterTX);

/* Loop forever */
while(1)
{

}
}

Original Attachment has been moved to: MPC5606S-UART_Interrupt.zip

Labels (1)
Tags (3)
0 Kudos
5 Replies

269 Views
martin_kovar
NXP Employee
NXP Employee

Hello,

flash target works correct. If you want to use RAM target, you have to modify RAM_VLE.prefix in your project and recompile it. Please see figure below:

pastedImage_1.png

Regards,

Martin

0 Kudos

269 Views
skysword
Contributor II

Hello,

      Thank you for solving my problem.

Use RAM target,In accordance with your way to modify the RAM_VLE.prefix can work properly .

But when I use flash target to debug, the emergence of such a mistake, this is why?

pastedImage_1.png

Is there a problem with you?

0 Kudos

269 Views
martin_kovar
NXP Employee
NXP Employee

Hello,

this error appears only, if you use Flash target? Is it correct?

Was the code for flash target correctly compiled? Which debug probe you use? Did you try to exit CodeWarrior, start it again and connect to board? Sometimes some strange mistakes appears with PEMicro debug probe.

Please write me back as much details as possible.

Regards,

Martin

0 Kudos

269 Views
skysword
Contributor II

Hello,

      Yes, when I used flash target just this error.

The code can be compiled correctly under flash target.I don't know what probe is, because I use this CodeWarrior time is not too long.I tried many times to exit CodeWarrior, and then restart the connection board, but the same phenomenon.

My IDE is codewarrior 10.7.

Microcontroller is MPC5606S.

Debugging tool is PE micro USB multilink.

  Annex is the project I use. You can give me a project, the right to use flash target debugging.

 suspect that there are errors in my engineering parameters. Thank you very much.

0 Kudos

269 Views
martin_kovar
NXP Employee
NXP Employee

Hello,

I tested your project on my side and it works correct to me. I have the same condition, CodeWarrior 10.7, USB Multilink and MPC5606S.

1) Could you please try to create new empty project, compile for Flash target and try to download into the microcontroller?

2) Try to disconnect USB cable from USB multilink, wait for a while and connect it again.

3) Also could you please check PEMicro drivers and eventually update it?

Do you get any other error than the one you posted above?

Regards,

Martin

0 Kudos