Hello All,
I need some help with interrupt driven serial comm on my 7026. I have single character transfer working fine but have difficulty converting this to multiple character.
I am new to serial comm so forgive any dumb questions.
For instance…
Once inside of the IRQ service function do I need to disable further interrupts while reading the incoming data?
The pseudocode should be like the following. But I tried this and it fails. I just transmits continuous “P” until reset… I am sending a fixed number (5 or 10) of bytes from hyperterm each time.
Check for IRQ
Loop (5x or 10x)
{
Wait for data_ready
Read
Echo
}
if ((IRQSTA & UART_BIT) == UART_BIT) //UART interrupt
{
if ((COMSTA0 & DR) == DR) // incoming data ready
{
for(i=0;i<5;i++)
{
rcv_char = ReadChar; //ReadChar includes the wait for data
RCV_BUF[i-1] = rcv_char;
COMTX = rcv_char;
}
switch(rcv_char)
…
The single byte code that works is:
if ((IRQSTA & UART_BIT) == UART_BIT) //UART interrupt
{
if ((COMSTA0 & DR) == DR) // incoming data ready
{
rcv_char = COMRX; /read
COMTX = rcv_char; //echo .
switch(rcv_char)
{
case ‘o’:
debug_state = OPEN;
break;
case ‘c’:
debug_state = CLOSE;
break;
case ‘h’:
debug_state = HOME;
break;
default:
break;
}
}
}