MPC56xx eSCI configuration

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

MPC56xx eSCI configuration

Jump to solution
3,289 Views
JonOgilvie
Contributor I

Hello all,

 

I've just got my shiny new MPC5668 dev board, but I can't get eSCI for RS232 output working right (or really at all).  There's no example code for this device around, either.

 

I think it's an initialization thing; after reset, TDRE is high.  I try to clear it, then send a character, but no character seems to get sent: I have my logic analyzer connected to the TX pin between the 5668 and the MAXIM RS232 chip on the dev board, and all that seems to happen is the pin goes low at reset, high when I switch the pad to function 1 (eSCI_A), and then stays there.

 

My code is attached, and should ideally just send one character over and over.  However, it never seems to send the first one despite me putting it in the data register.

 

It should be sending 9600 baud, no parity, 8 data, 1 stop. 

 

Thanks in advance for any help.

Labels (1)
0 Kudos
1 Solution
1,908 Views
JonOgilvie
Contributor I

Funny seeing you here!  We graduated together, I think.

 

Anyway, it turns out it is mostly the same as the 5517... the difference in header files requires some small changes.

 

The following code worked to send the whole ASCII table over the RS232 (it's mostly the same as the original code I posted, but I removed the part about clearing CR1 and CR2, and moved MDIS = 0 up to the top).

 

 

int main(void) { volatile int i=0; volatile char charToSend = 32;  //Set functions for port D, pad 12 to eSCI (do the same for pad 13 for receive) SIU.PCR[60].B.PA = 1;  //Enable the module ESCI_A.CR2.B.MDIS = 0;    //Set 9600 baud, for default clock of 16MHz ESCI_A.CR1.B.SBR = 104;   //Set transmit enable ESCI_A.CR1.B.TE = 1;   //Set 8 data bits, 1 even parity bit, 1 stop bit ESCI_A.CR1.B.M = 1; ESCI_A.CR1.B.PE = 1; ESCI_A.CR1.B.PT = 0;   /* Send ASCII table then loop forever */ while (1) {   if(ESCI_A.SR.B.TDRE)  {   //Clear the interrupt flag   ESCI_A.SR.B.TDRE = 1; //write 1 to clear     i++;     if(charToSend<255){    ESCI_A.DR.B.D = charToSend;    charToSend++;   }  } }}

 

 

View solution in original post

0 Kudos
4 Replies
1,908 Views
jonr
Contributor III

There is lots of example code available at ecu.zeeff.com

0 Kudos
1,908 Views
AdamShiemke
Contributor I

I believe the 5668 SCI is the same as the 5517 SCI (I don't have a 5668 to test on yet). The following has been ripped from sample code for the 5517:

 

 

ESCI_A.CR2.R = 0x2000;      /* Module is enabled (default setting ) */ESCI_A.CR1.R = 0x01A1000C;  /* 9600 baud, 8 bits, no parity, Tx & Rx enabled */SIU.PCR[54].R = 0x400;      //this is the pin for 5517: your pin will be differentwhile (ESCI_A.SR.B.TDRE == 0) {}       /* Wait for transmit data reg empty = 1 */ESCI_A.SR.R = 0x80000000;              /* Clear TDRE flag */ESCI_A.DR.B.D = '!';          /* Transmit 8 bits Data */

 Hopefully I'll get my 5668 board soon so I can be of more help.

 

0 Kudos
1,909 Views
JonOgilvie
Contributor I

Funny seeing you here!  We graduated together, I think.

 

Anyway, it turns out it is mostly the same as the 5517... the difference in header files requires some small changes.

 

The following code worked to send the whole ASCII table over the RS232 (it's mostly the same as the original code I posted, but I removed the part about clearing CR1 and CR2, and moved MDIS = 0 up to the top).

 

 

int main(void) { volatile int i=0; volatile char charToSend = 32;  //Set functions for port D, pad 12 to eSCI (do the same for pad 13 for receive) SIU.PCR[60].B.PA = 1;  //Enable the module ESCI_A.CR2.B.MDIS = 0;    //Set 9600 baud, for default clock of 16MHz ESCI_A.CR1.B.SBR = 104;   //Set transmit enable ESCI_A.CR1.B.TE = 1;   //Set 8 data bits, 1 even parity bit, 1 stop bit ESCI_A.CR1.B.M = 1; ESCI_A.CR1.B.PE = 1; ESCI_A.CR1.B.PT = 0;   /* Send ASCII table then loop forever */ while (1) {   if(ESCI_A.SR.B.TDRE)  {   //Clear the interrupt flag   ESCI_A.SR.B.TDRE = 1; //write 1 to clear     i++;     if(charToSend<255){    ESCI_A.DR.B.D = charToSend;    charToSend++;   }  } }}

 

 

0 Kudos
1,908 Views
AdamShiemke
Contributor I

I know... small world, eh?

0 Kudos