Nick Xanalatos

S12 SCI stop receiving after time - 9S12DP512

Discussion created by Nick Xanalatos on Jun 22, 2008
Latest reply on Jun 29, 2008 by Nick Xanalatos
I've developed an automation application based on Elektonikladen S12 Compact board with 9S12DP512. It uses SCI1 to coomunicate with a PC via 485 for data aquisition. A number of same boards (5-6 up to now) are on the 485 bus and PC is querying them to get data. It works FINE for some days and then the one S12 PLC   will stop receiving at all any data, until reset (power off reset OR reset button). Serial I/O is at 4800 and pulled....
 
Init code below :
initSCI1(BAUD4800);                          // calls routine below....
 
void initSCI1(UINT16 bauddiv) {
 SCI1BD  = bauddiv & 0x1fff;                    // baudrate divider has 13 bits
 SCI1CR1 = 0;                                           // mode = 8N1
 SCI1CR2 = BM_TE+BM_RE;               // Transmitter + Receiver enable
}
 
 
for the actucal receiveing code shown below is executed in a pooled way :
 
void GetSerial(void){
  char c;
  char bError;
  long i=0;
 
  ResetCOP;                                                       // we are using COP.........
// error checking code below was put for troubleshooting....
//Check for Frame Error
 if ((SCI1SR1 & BM_FE) > 0)
  { 
    c = SCI1DRL;     // Get Data to clear Flag..
    clearLCD();
     writeStrLCD("FRAME ERROR " ) ;
     sound(30,30);
     delay(1000);
     sound(40,40);
     while (1); {} 
 }
//Check for Overrun Error
 if ((SCI1SR1 & BM_OR) > 0)   // test frame...
  { 
 c = SCI1DRL;     // Get Data to clear Flag..
//    just clear and exit.........  
 }
// General Errors Check....
   c=SCI1SR1 & 0x07;
if (c > 0)
  {
   bError=c;
   c = SCI1DRL;     // Get Data to clear Flag..
   clearLCD();
   writeStrLCD("ERROR..  " ) ;
   writeIntLCD(bError & 0x0f); 
   sound(30,30);
   delay(1000);
   sound(40,40);
   delay(9000); 
   while (1); {} 
 }
 
// debug.....  sound tick just before test for first byte...
   PTT ^= 0x04;            // click to speaker....
 
 if ((SCI1SR1 & BM_RDRF) == 0)
  { 
   return;
 }
 c = SCI1DRL;     // Get Data..
// debug  Led Flash IF just one byte received...
  onLED;
  delay(30);
  offLED;
........................................................
..........................................................
..............................................  more code follwes.......
 
When program works OK it goes into GetSerial sub and you can hear the clicks from
                PTT ^= 0x04;  
 
When a byte from PC arrives also code below is executed and you see on board LED flashing..
            onLED;
            delay(30);                // 30 msecs...
            offLED;
 
When Rx stucks Off (after hours to days) you can only hear the clicks from PTT but NO led, so i assume (???) that
    if ((SCI1SR1 & BM_RDRF) == 0)
    { 
      return;
     }
 
is NOT seeing incoming byte.......
 
At the same time byte(s) from the PC is seen and received from other S12 PLCs connected to the same bus......
 
I was able to simulate the problem apart from installation site on my PC.  When stuck it will not recover if not reseted...........It will not also recover when  i did (manually) an INITSCI1, still at the same time ALL other program in the S12 is OK !!
 
There are NO SCI interrupts (as seen by initilisation code).
 
Code was added to try to trace any Frame errors, still no indication of that, since program would halt in frame err.. (code seen below)
 
//Check for Frame Error
 if ((SCI1SR1 & BM_FE) > 0)
  { 
     c = SCI1DRL;     // Get Data to clear Flag..
    clearLCD();
    writeStrLCD("FRAME ERROR " ) ;
    sound(30,30);
    delay(1000);
    sound(40,40);
     while (1); {} 
 }
 
 
Any possible H/W issues refering to proper 485 operation were taken out since i changed from SCI1 to SCI0 which is RS232 and problem is exactly the same....
 
 
I would appreciate very much any help since we're trying to resolve it form 2-3 months
Thanks in advance!
 
Nick
 
 
Added p/n to subject.
 


Message Edited by NLFSJ on 2008-06-23 11:32 AM

Outcomes