MC68302 Applications
MOTOROLA
MC68302 USER’S MANUAL
D-11
e. Clear all status bits to zero (the default condition).
f. Set (PRD -> Empty) = 1.
g. Move PRD to point to the next BD (If the wrap bit is set, point to the first BD).
If the interrupt was due to a buffer being transmitted, perform the following confirm pro-
cess:
2. While (CTD -> Ready) = 0 and (CTD -> data length) > 0, do the following:
/* Look at frames that have been transmitted, but not confirmed */
a. Check for errors in the BD.
b. Clear all status bits to zero (the default condition).
c. Clear out the data length field so that it is zero to start with. This procedure al-
lows new data be placed in this transmit buffer by the transmit algorithm.
d. Move CTD to point to the next BD. (If the wrap bit is set, point to the first BD.)
Finally:
3. Clear the SCC bit in the in-service register (ISR) of the interrupt controller. This is stan-
dard procedure.
4. Return from interrupt.
D.3.7 Final Comments
Note that nowhere in the algorithm does RBD# or TBD# need to be read. The empty and
ready bits provide all the necessary information.
Whether receiving buffers or confirming buffers, the interrupt routines deal with all the buff-
ers they can before the interrupt routine is exited. This approach is not mandatory, but if not
all buffers are dealt with, then some provision needs to be made for getting the work done
without waiting for another interrupt.
For frame-oriented protocols such as HDLC, the user may wish to only process frames, not
buffers. In this case, the algorithm would be the same, but the interrupt mask would be set
for frame interrupts only.
D.3.8 HDLC Code Listing
The following code shows the initialization of the HDLC protocol and the implementation of
the buffer processing algorithms just described. HDLC frames are continuously transmitted
and received in the SCC loopback mode.
*************************** BUFFER PROCESSING CODE**************************
************************************EQU TABLE******************************
* The following three values are application dependent
BASE
EQU
$0700000
INIT
EQU
$0030300
INT_VEC
EQU
$0031000
* Commonly used Registers and Parameters
BAR
EQU
$0F2
SCR
EQU
$0F4
CKCR
EQU
$0F6
GIMR
EQU
BASE + $812
IPR
EQU
BASE + $814
;This is set according to the val in BAR
;Initialization Routine
;Interrupt Vector for SCC1
;Base Address Register
;System Control Register
;Clock Control Register
;Global Interrupt Mode Register
;Interrupt Pending Register