#include "UARTIntC.h"
#include "delays.h"
#include <p18f4620.h>
void low_isr(void);
// serial interrupt taken as low priority interrupt
#pragma code uart_int_service = 0x08
void uart_int_service(void)
{
_asm goto low_isr _endasm
}
#pragma code
#pragma interruptlow low_isr save=section(".tmpdata")
void low_isr(void)
{
// call of library module function, MUST
UARTIntISR();
}
void main(void)
{
// Test data array
unsigned char cArray[10]
= { 'A','B', 'C', 'D', 'E', 'F', 'G','H','I' , 'J'};
// temporary local array
unsigned char writtenArray[10];
// local variables for all test cases and their initialisation
unsigned char chData;
unsigned char *pReadArray;
unsigned char *pWriteArray;
unsigned char j = 0;
unsigned char i = 0;
unsigned char l = 0;
unsigned char k = 0;
pReadArray = pWriteArray = writtenArray;
// call of library module , MUST
UARTIntInit();
// TEST
// Chunk of data is sent from PC to micro. Data received at micro is
// read in to temporary buffer. The data is sent back to PC. Here
// reception and transmission is done independently.
while(1)
{
l = 0;
l = UARTIntGetRxBufferDataSize();
while(l > 0)
{
if(UARTIntGetChar(pReadArray))
{
l--; pReadArray++;
if(pReadArray == (writtenArray + 10))
pReadArray = writtenArray;
}
}
if((pWriteArray < pReadArray) || ((pWriteArray - pReadArray) == 9 ))
{
if(!vUARTIntStatus.UARTIntTxBufferFull)
{
UARTIntPutChar(*pWriteArray);
i--; pWriteArray++;
if(pWriteArray == (writtenArray + 10))
pWriteArray = writtenArray;
}
}
}
}