I Can not write SCI1D register.

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

I Can not write SCI1D register.

557 Views
jungwoojin
Contributor I

hi ~

i use 8 bit MCU MC9S08AW16(freescale)

i worked that UART(SCI) communicate between mc9s08aw16(freescale) and XC2765(infineon).

communication procedure is shown below.

1. XC2765 send char 'R' to Mc9s08aw

2. if Mc9s08aw receive the 'R'. the Mc9s08 will Send char 'W' to XC2765

but  i have a problem,

MC9S08AW can read 'R'. however MC9S08AW does not send the 'W' .

MC9S08AW continues to send the 'R' rather than 'W'

when I  write anything in SCI1D register. the SCI1D register not written anyting.

SCI1D regi only store the receiving data.

plz~tell me what to  solve this problem.

 

//==============================================================================

i use CW processor expert

 

void AS1_Init(void)

{

  SerFlag = 0x00;                      /* Reset flags */

  OnFreeTxBuf_semaphore = FALSE;       /* Clear the OnFreeTxBuf_semaphore */

  AS1_InpLen = 0x00;                   /* No char in the receive buffer */

  InpIndxR = InpIndxW = 0x00;          /* Reset indices */

  AS1_OutLen = 0x00;                   /* No char in the transmit buffer */

  OutIndxR = OutIndxW = 0x00;          /* Reset indices */

  /* SCI1C1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */

  setReg8(SCI1C1, 0x00);               /* Configure the SCI */

  /* SCI1C3: R8=0,T8=0,TXDIR=0,TXINV=0,ORIE=0,NEIE=0,FEIE=0,PEIE=0 */

  setReg8(SCI1C3, 0x00);               /* Disable error interrupts */

  /* SCI1S2: LBKDIF=0,RXEDGIF=0,??=0,RXINV=0,RWUID=0,BRK13=0,LBKDE=0,RAF=0 */

  setReg8(SCI1S2, 0x00);               

  /* SCI1C2: TIE=0,TCIE=0,RIE=0,ILIE=0,TE=0,RE=0,RWU=0,SBK=0 */

  setReg8(SCI1C2, 0x00);               /* Disable all interrupts */

  SCI1BDH = 0x00;                      /* Set high divisor register (enable device) */

  SCI1BDL = 0x19;                      /* Set low divisor register (enable device) */

      /* SCI1C3: ORIE=1,NEIE=1,FEIE=1,PEIE=1 */

  SCI1C3 |= 0x0F;                      /* Enable error interrupts */

  SCI1C2 |= ( SCI1C2_TE_MASK | SCI1C2_RE_MASK | SCI1C2_RIE_MASK); /*  Enable transmitter, Enable receiver, Enable receiver interrupt */

}

 

 

 

byte AS1_SendChar(AS1_TComData Chr)

{

  if (AS1_OutLen == AS1_OUT_BUF_SIZE) { /* Is number of chars in buffer same as a size of the transmit buffer */

    return ERR_TXFULL;                 /* If yes then error */

  }

  EnterCritical();                     /* Save the PS register */

  AS1_OutLen++;                        /* Increase number of bytes in the transmit buffer */

  OutBuffer[OutIndxW] = Chr;           /* Store char to buffer */

  OutIndxW = (byte)((OutIndxW+1) & (AS1_OUT_BUF_SIZE-1)); /* Update index */

  SCI1C2_TIE = 0x01;                   /* Enable transmit interrupt */

  ExitCritical();                      /* Restore the PS register */

  return ERR_OK;                       /* OK */

}

 

ISR(AS1_InterruptTx)

{

  byte OnFlags = 0x00;                 /* Temporary variable for flags */

 

 

  if (SerFlag & RUNINT_FROM_TX) {      /* Is flag "running int from TX" set? */

    OnFlags |= ON_TX_CHAR;             /* Set flag "OnTxChar" */

  }

  SerFlag &= ~RUNINT_FROM_TX;          /* Reset flag "running int from TX" */

  if (AS1_OutLen) {                    /* Is number of bytes in the transmit buffer greater than 0? */

    AS1_OutLen--;                      /* Decrease number of chars in the transmit buffer */

    SerFlag |= RUNINT_FROM_TX;         /* Set flag "running int from TX"? */

    (void)SCI1S1;                      /* Reset interrupt request flag */

    SCI1D = OutBuffer[OutIndxR];       /* Store char to transmitter register */

    OutIndxR = (byte)((OutIndxR+1) & (AS1_OUT_BUF_SIZE-1)); /* Update index */

  } else {

    if (!OnFreeTxBuf_semaphore) {

      OnFlags |= ON_FREE_TX;           /* Set flag "OnFreeTxBuf" */

    }

    SCI1C2_TIE = 0x00;                 /* Disable transmit interrupt */

  }

  if (OnFlags & ON_TX_CHAR) {          /* Is flag "OnTxChar" set? */

    AS1_OnTxChar();                    /* If yes then invoke user event */

  }

  if (OnFlags & ON_FREE_TX) {          /* Is flag "OnFreeTxBuf" set? */

    AS1_OnFreeTxBuf();                 /* If yes then invoke user event */

  }

}

 

 

 

void  Main(void)

|

byte W;

W='R';

|

|

AS1_SendChar(W);

|

|

Labels (1)
0 Kudos
Reply
1 Reply

380 Views
jungwoojin
Contributor I

Add inform.

the baud rate is 10000 and No parity.

also i'm already check the the SCI1S1 regi (= TDRE and TC is set).

however i can not write SCI1D regi.

0 Kudos
Reply