Hi, I basically used the methodology provided by keil on this website. I am able to set up the PEC and it transmits data out of the Rs232 port. Unfortunately it appears to be transmitting data from a different location than the one I loaded to it (it sends the first byte correctly and all other bytes are 0xFF)! This is my first attempt at using a PEC so I am sure that I am doing something wrong. Here is my code (you will see hacks in it).
void vSendSerData( BYTE *pbBuf, BYTE bLen ) /******************************************************************************* Description: This routine sends bLen bytes to the serial port transmitter, waiting for the port to empty before sending the next character. Inputs: pbBuf - Pointer to byte[s] to send bLen - Number of byte[s] to send Outputs: NONE Globals: g_bitCommsType - Indicates Rs485 or Rs232 g_bitCommsDir - Sets Rs485 direction (transmit or receive) m_bTransmitByteCount = Transmit byte count used by trasmit interrupt m_bTransmitByte = Current byte to transmit *******************************************************************************/ { static BYTE huge jakdata[5]= "Jerk"; bLen =4; /* If this transmission is meant for the Rs485 bus, disable recieve interrupts and set the Rs485 line for transmission */ if (g_bitCommsType == SELECT_RS485) { ASC_vReceiverDisable(); g_bitCommsDir = TRANSMIT_485; } /* Set up PEC 0 (Peripheral Event Controller 0) to: increment the source pointer on each transfer, set the transfer size to a byte and set the number of bytes to transfer to bLen */ PECC0 = 0x500 | (WORD)bLen; /* PEC source pointer is set to the next character in buffer */ SRCP0 = _sof_(&pbBuf[1]); SRCP0 = _sof_(&jakdata[1]); /* PEC destination pointer is set to serial transmit buffer register */ DSTP0 = (WORD)&S0TBUF; /* enable transmit interrupt */ /* transmit interrupt priority level(ILVL) = 14 */ /* transmit interrupt group level (GLVL) = 0 */ S0TIC = 0x0078; /* Set flag indicating that transmission isn't complete */ m_bTxDone = FALSE; /* Put the first byte from the buffer into the transmitter port, PEC 0 will process the rest */ // S0TBUF = pbBuf[ 0 ]; S0TBUF = jakdata[ 0 ]; /* Wait for the PEC to finish transmitting the message */ while ( m_bTxDone == FALSE ) { os_delay_task(1); } }/* vSendSerData() */ void vSerialTransmitInterrupt(void) interrupt SERTXINT /******************************************************************************* Description: This is the transmit interrupt handler. This routine is called when a character has been transmitted from the serial port. The routine moves the received character to a recirculating buffer, then increments the buffer pointer. If the buffer pointers are equal after the increment, the overrun flag is set. Inputs: NONE Outputs: NONE Globals: m_bTransmitByteCount - Pointer to total transmit buffer count m_bTransmitByte - Pointer to current transmit buffer index *******************************************************************************/ { S0TIC = 0; /* Transmission complete, enable receiver if necessary */ if (g_bitCommsType == SELECT_RS485) { g_bitCommsDir = RECEIVE_485; S0REN = 1; /* enable the ASC receiver */ } /* Set flag indicating that transmission is complete */ m_bTxDone = TRUE; }/* vSerialTransmitInterrupt() */ My map file is as follows: START STOP LENGTH TYPE ALIGN TGR GRP COMB CLASS SECTION NAME =============================================================================== 000000H 0001FFH 000200H --- --- --- --- --- * INTVECTOR TABLE * 00F800H 00FBFFH 000400H --- --- --- --- --- * SYSTEM STACK * 00FC00H 00FC1FH 000020H DATA WORD --- --- --- *REG* ?C_MAINREGISTERS 00FC20H 00FC3FH 000020H DATA WORD --- --- --- *REG* rtx_clk_rb 00FC40H 00FC5FH 000020H DATA WORD --- --- --- *REG* can_isr_rb 00FC60H 00FC7FH 000020H DATA WORD --- --- --- *REG* rtx_int_rb 00FC80H 00FCA5H 000026H DATA WORD --- 3 PUBL IDATA0 ?ID0?FREQINP 00FCA6H 00FCA8H 000003H DATA BYTE --- 3 PUBL IDATA0 ?ID0?FSTCOMMS 00FCAAH 00FCCDH 000024H DATA WORD --- 3 PUBL IDATA0 ?ID0?RTXPSREQ 00FCCEH 00FCCFH 000002H DATA WORD --- 3 PUBL IDATA0 ?ID0?RTXHARDW 00FCD0H 00FCDFH 000010H DATA WORD --- 3 PRIV IDATA0 ?ID0?RTXPSRQA 00FCE0H 00FCFFH 000020H --- --- --- --- --- * PEC MEMORY * 00FD00H 00FD07H 000008H DATA WORD --- 3 PRIV IDATA0 ?ID0?RTXSWTCH
Mike, Thanks so much for your help. It was just what I needed. Unfortunately, our board has no RAM (other than on-chip RAM) at addresses 0xC000-0xFFFF. I was however able able to make the system work using idata. Unfortunately, we don't have enough idata left to hold the entire transmit buffer so we may have to settle for our current system without PEC transfers. In any event, you saved me alot of headaches with your suggestion. Thank you!
Hold on a seond. I enabled the XRAM and now I have 8 kbytes of memory to work with. This is going to work as slick as snot!! Yehaw!!!