SCI Transmit Interrupts

Started by dibosco March 30, 2003
I've spent almost two days trying to make the serial transmit
interrupts working without any success! So, after crawling up several
walls, I thought I'd see if anyone can point out what I'm doing wrong.

What I have always come across with UARTs in the past is a flag that
indicates whether the transmit data register is empty. This would
appear to be the TDRE flag. It would also appear that this initiates
an interrupt and I'm guessing that this is the Transmit Complete
interrupt; ie vector 50.

However, even though TDRE flag gets set, I am not getting an
interrupt to vector 50.

I've set GPR12 thus:

asm (bfset #$700,X:GPR12);

If I try the other transmit interrupt and set GPR12 as follows:

asm (bfset #$7000,X:GPR12);

The program just gets stuck forever going into vector 51's address.

I have the follwing routine for writing data to an output buffer or
directly to the SCI data register.

void SendByte(char SByte)

unsigned int temp;

temp = SCI0_SCISR;
if ((temp & 0x8000) == 0x8000) // Check to see if the transmitter is
SCI0_SCIDR = SByte; // Clear the TDRE flag
scTxBuf[InPtr] = SByte; // Transmitter is full, fill up an output
InPtr ++;
if (InPtr == TXBUFLEN)
InPtr = 0;

The above routine fills and output buffer that should get emptied by
the Tx Interrupt below:

#pragma interrupt
void Tx0Int(void)

unsigned int temp;

if (InPtr != OutPtr) // See if there's anything to transmit
SCI0_SCIDR = scTxBuf[OutPtr];
OutPtr ++;
if (OutPtr == TXBUFLEN)
OutPtr = 0;


So, once a byte is transmitted, the interrupt routine is called and if
there's some data in the transmitter it gets sent.

The problem being, the interrupt never gets called! This is a
technique I've used for fifteen years on a variety of processors from
8032, through 68k, AVRs, 80C166 etc etc with no problem!

The crux of the matter would appear to be the damn interrupt n.ever
getting called.

For completeness, here's the UART initialisation:

void InitUART()
// 19k2 baud rate
SCI0_SCIBR = 130;


// UART 0 Rx int lowest priority
asm (bfset #$0010,X:GPR13);
// UART 0 Tx int lowest priority
asm (bfset #$700,X:GPR12);