Silicon Laboratories SI2494/39 manual Polling HIR1 Method, Interrupt Service Routine ISR Method

Models: SI2493/57/34/15/04 SI2494/39

1 304
Download 304 pages 21.65 Kb
Page 293
Image 293

AN93

Polling HIR1 Method

Transmitting and receiving data to and from the modem is accomplished by polling HIR1 status bits TXE and REM. Polling is implemented by the following code fragment, excerpted from modemCommunicationUpdate(), which must run in an infinite loop:

static char bytesToSend == 12; // Declared in modemCommunicationUpdate()

if ( ( readModem( HIR1 ) & SiREM ) == 0 && rxBufferSize < MODULUS_MASK )

{

readModemByte;

 

}

 

if ( gUARTToModemBufferSize > 0 )

// If there are data to be sent

{

 

if ( bytesToSend == 12 )

// Check TXE only every twelve bytes sent

{

 

status = readModem( HIR1 ) & SiTXE;

if ( status )

// If transmit FIFO empty

{

 

writeModem( HIR0, pullByteForModem(), 0xFF ); bytesToSend--;

}

}

else // No need to check TXE because transmit FIFO is twelve deep

{

writeModem( HIR0, pullByteForModem(), 0xFF ); bytesToSend--;

//If the bytes to send count = 0, reset the count if ( bytesToSend == 0 )

{

bytesToSend = 12;

}

}

}

Interrupt Service Routine (ISR) Method

Transmitting and receiving data to and from the modem is accomplished by servicing the interrupts generated by the modem. The interrupt sources are described below. Whenever new communication is initiated after a period of idling with respect to the TXE interrupt, the interrupt must be "jump-started" by calling the interrupt service routine manually.

RXF Interrupt: Receive FIFO Almost Full

The RXF bit indicates the status of the receive FIFO. If this bit is set, the FIFO is either full (contains 12 bytes) or almost full (contains 10 or 11 bytes). There are two ways to clear this interrupt: the RXF bit in HIR1 can be cleared by the host, or enough bytes can be read from the receive FIFO to leave 9 bytes or less, thus removing the condition for the interrupt. If the host clears the RXF bit, the interrupt is disabled. The interrupt can be rearmed only when the receive FIFO drops below the ten-byte threshold. The interrupt can then trigger again when the receive FIFO fills up to ten bytes or more.

Rev. 1.3

293

Page 293
Image 293
Silicon Laboratories SI2494/39, SI2493/57/34/15/04 manual Polling HIR1 Method, Interrupt Service Routine ISR Method