19.08.2013 Views

AN2120: Connecting an M68HC08 Family Microcontroller to an ...

AN2120: Connecting an M68HC08 Family Microcontroller to an ...

AN2120: Connecting an M68HC08 Family Microcontroller to an ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Application Note<br />

Listing 2 The listing shows the modem service routine that must be called from<br />

the ISR of the SCI driver.<br />

The method just described allows great flexibility while h<strong>an</strong>dling the<br />

FIFO. For inst<strong>an</strong>ce, <strong>to</strong> retrieve the number of characters s<strong>to</strong>red in the<br />

FIFO, the software only needs <strong>to</strong> subtract dataSlot from emptySlot.<br />

Another example is the operation <strong>to</strong> flush the contents of the FIFO will<br />

simply require the statement dataSlot = emptySlot.<br />

The code <strong>to</strong> dequeue (pull out of queue) a character from the FIFO is<br />

shown in Figure 28.<br />

BYTE ModemGetch (void) {<br />

BYTE c = 0;<br />

if (mDataSlot != mEmptySlot) {<br />

c = ModemBuffer [mDataSlot];<br />

mDataSlot++;<br />

if (mDataSlot > MODEM_BUFFER_SIZE) mDataSlot = 0;<br />

return(c);<br />

}<br />

else {<br />

return (BYTE)0x00;<br />

}<br />

}<br />

Figure 28. Code <strong>to</strong> Dequeue a Character from the Modem FIFO<br />

Listing 3 Two import<strong>an</strong>t functions are also defined inside the modem module: the<br />

Tr<strong>an</strong>smit() <strong>an</strong>d Waitfor() functions. The first tr<strong>an</strong>smits data <strong>to</strong> the modem<br />

while the second waits for <strong>an</strong>y particular character or a string of<br />

characters before it times out. When used <strong>to</strong>gether, both functions<br />

provide support for complex scripts required for SLIP sessions.<br />

Obviously, those scripts will be built in the ROM code, making it difficult<br />

<strong>to</strong> maintain in some applications.<br />

<strong>AN2120</strong><br />

38 MOTOROLA

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!