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

HELP!! how to use PEC to send data to serial interface(TXD)

The Code runs in XC164CM(C166 core)
The following program shows how to program PEC channel 0 for data transfers to the serial port transmit buffer, but I can't see anything from TXD. Whether somebody knows how to resolve it?

//========== main.c ======================
#include<reg166.h>
#include<INTRINS.H>

#pragma PECDEF (0)

const char string[] = "0123456789\n";

void serial_PEC0_setup(void)
{
PECC0 = 0x0500 |
((sizeof(string)/sizeof(string[0])) - 1 );
SRCP0 =_sof_(string);
DSTP0 =(unsigned int) &S0TBUF;
}

void Tx_IRQ(void) interrupt S0TINT = 42
{
serial_PEC0_setup();
}

void serial_setup(unsigned int baurate)
{
S0BG =(16000000UL/(32UL*(unsigned long)
baurate)) - 1;
DP3 |= 0x0400;
DP3 &= ~0x0800;
P3 |= 0x0400;
S0CON = 0x8011; // 8, N, 1
S0TIC = 0x00F8;

serial_PEC0_setup();

IEN = 1;
}

void main(void)
{
serial_setup(19200);
while(1);
}

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

0