Example for parity checking on ADuCM361

Document created by analog-archivist Employee on Feb 23, 2016
Version 1Show Document
  • View in full screen mode

I would like to ask you if you have any example for parity checking? I have a
bit problem with following code:
 
...
ucCOMIID0 = UrtIntSta(pADI_UART);
if ((ucCOMIID0 & 0x4) == 0x4)
{  
ucCOMLSR = UrtLinSta(pADI_UART);
if((ucCOMLSR & COMLSR_PE) != COMLSR_PE)
{  
.....
}  
}
...
 
Code is placed in the UART interrupt and does receive bytes correctly, but
parity check (second if) seems to be ignored even I have uart set up like
following:
UrtCfg(pADI_UART,B1200, COMLCR_WLS_7BITS,COMLCR_PEN_EN | COMLCR_EPS_EN);
 
1.Please be so kind and send me example of using parity checking.
2.Please also send me the initialization routine.

 

1.Normally we test the UART using the PC. What we do to trigger the parity
check is to set up the PC with odd parity and the ADuCM360 with even parity (or
the other way around).
Then, if a character is sent from the PC we hit a breakpoint in the interrupt
handler where we check for a parity error. We will always hit the breakpoint if
the PC is configured with the other parity.

This is the interrupt handler I have that works:

Uart handler
{             
      ucCOMSTA0 = UrtLinSta(pADI_UART);
      ucCOMIID0 = UrtIntSta(pADI_UART);
      if ((ucCOMIID0 & 0x2) == 0x2)                         // Transmit buffer
empty
       {
                  ucTxBufferEmpty = 1;
       }      
      if ((ucCOMIID0 & 0x4) == 0x4)                         // Receive byte
       {
                ucComRx            = UrtRx(pADI_UART);
       }
       if ( (ucCOMSTA0& COMLSR_PE) == COMLSR_PE

       {
Breakpoint here.
//enters if statement if parity is incorrect

          ucCOMSTA0++;
          ucCOMSTA0--;
       }
}

2.We used the initialization code as you mentioned in your message :

UrtCfg(pADI_UART,B1200, COMLCR_WLS_7BITS,COMLCR_PEN_EN | COMLCR_EPS_EN);

The rest of it, such as interrupt configuration, GPIO settings etc, is exactly
the same as the project on the CD/ftp.

Attachments

    Outcomes