AnsweredAssumed Answered

MM9Z1_638 SCI Half-Duplex mode, RDRF not set

Question asked by joek on Jan 7, 2016
Latest reply on Jan 7, 2016 by joek

Hello,

 

The MM9Z1_638 has an S12Z processor and S08SCIV4 SCI module.  I want to use the SCI in one-wire, half duplex mode.  The physical pin I am using is the LIN pin.  So, I have set both LIN_TX.FROMSCI and LIN_RX.TOSCI.  I have a terminal application running on my PC and a USB-LIN adapter connected (19,200 baud, N, 8, 1).

 

I can send data from the processor to the terminal with no problems.  But, I cannot receive any data.  RDRF is never set.  I do see RXEDGIF set when I send a character.  This implies the signal is making it to the SCI module.  I have checked the baud rate settings and confirmed that a sent character (e.g. 'U') has exactly the same scope waveform on the LIN pin as a received character.  So I think the baud rate setting is OK.  I did find a bug in the MM9Z1_638 example code in this area, but fixed it (baud rate was off by 2.5%).

 

All SCI interrupts are disabled.  I want it to work via polling first, then I will implement the interrupts.  I believe I should be able to send a character from the terminal to the LIN pin and see RDRF set.

 

I think I need to have LOOPS=1 and RSRC=1 for one-wire mode.  In the process of debugging, I cleared RSRC=0 to see what would happen.  It turns out that in this mode (internal loopback) when I send a character by writing to SCID, the receiver sets RDRF.  Great!  But as soon as I set RSRC=1, RDRF never sets.

 

Here is the SCI initialization code:

 

void SCIInit(void)  {

     B_SCIBD = (u16)(25ul*1000000ul/SCI_BAUD/16ul);

     B_SCIC1 = B_SCIC1_DPD1_MASK | B_SCIC1_DPD0_MASK | B_SCIC1_LOOPS_MASK | B_SCIC1_RSRC_MASK;

     B_SCIC2 = B_SCIC2_TE_MASK|B_SCIC2_RE_MASK;  // enable rx and tx

     B_SCIC3 = 0x00;

}

 

And here is the receive function I call repeatedly from the main loop:

 

char SCIRec(void) {

     if (B_SCIS1_RDRF) {

          return B_SCID;

     }

     else {

          return 0x00;

       }

}

 

I send characters from the terminal to the LIN pin and the debugger will never break on "return B_SCID;", but if I halt execution I can see RXEDGIF has been set.  If I modify the above code to clear RSRC (internal loopback mode) and send a character by writing to SCID, then the debugger will break on the "return B_SCID;" line.

 

Thank you for your help!

Outcomes