This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ASC0 in loopback mode

Hallo everyone,

I'm trying to write a serial port routine using the loopback mode for the XC167CI. I have data stored in an array 'tx_buf' that is transmitted via serial interface using the 'send_tx_buf'-function and the ISR 'serial_TX_irq'. The data currently being transmitted should be received simultaneously in the receive buffer. Simulating my program in µVision3 debug-mode no data appears at RBUF, so that the receive ISR 'serial_RX_irq' is never used, except for calling it especially with 'ASC0_RIC_IR = 1;'. But because of the empty RBUF nothing is stored in the receive buffer 'rx_buf' of course.

The important parts of my program are defined as follows:

// send data from tx_buf via serial interface
void send_tx_buf (void)
{
  int i;
  for(i=0;tx_out<15;i++)
  ASC0_TIC_IR = 1; 	// serial transceive interrupt to start transmission of tx_buf
}


void serial_TX_irq (void) interrupt ASC0_TINT_VEC = 42
{
  ASC0_TBUF = tx_buf [tx_out++];  // transmit the next character
// ASC0_RIC_IR = 1;
}


void serial_RX_irq (void) interrupt ASC0_RINT_VEC = 43
{
  rx_buf [rx_in++] = ASC0_RBUF;
}


// Init serial interface
void init_rs232 (void)
{

#ifndef Monitor
  P3  |= 0x0400;  // set port 3.10 output latch (TXD)
  DP3 |= 0x0400;  // configure port 3.10 for output operation. ( TXD output)
  DP3 &= 0xF7FF;  // configure port 3.11 for input operation. ( RXD input)

  ASC0_TIC = 0x0048;  // enable serial transmit interrupt level 2
  ASC0_RIC = 0x0044;  // enable serial receive interrupt level 1

// Set Baudrate (using Fixed Input Clock Divider)
  ASC0_BG  = 0x40;    // set baudrate to 19.2 kbit/s
  ASC0_CON = 0xC011;  // set serial mode  (R, LB, REN = 1; M = 001)

#endif
  ALTSEL0P3 |= 0x0C03;
}

Could anybody give me a hint?

Thanks in advance,
Daniel

0