Hi to all,
I have written a C program that transmits 4 byes of data in UART using interrupt routine.
My problem is that the interrupt is always ON, how I wrote a right routine that transmit 1 byte wait until the end of the byte transmitted (go to main loop), and go back to the interrupt routine to send the next byte ??
I have written a C program that transmits 4 byes of data in UART using interrupt routine.
My problem is that the interrupt is always ON, how I wrote a right routine that transmit 1 byte wait until the end of the byte transmitted (go to main loop), and go back to the interrupt routine to send the next byte ??
Code:
TXIE = 1;
TXEN = 0;
ei();
/*------------------------------------------------*/
buff[0]=0x5;
buff[1]=0x6;
buff[2]=0x7;
buff[3]=0x8;
BuffCounter = 0;
TXEN = 1;//Start interrupt
...
void interrupt sys_int(void)
{
if (TXIF == 1)
{
if (TRMT == 1)
{
if (BuffCounter <4)
{
TXREG = buff[BuffCounter++];
TXEN = 1;
}
else
TXEN = 0;
}
}
}