Freescale Semiconductor Microcontrollers User Manual

Page 317

Advertising
background image

HC08 Full Chip Simulation

Configuration Procedure

317

Microcontrollers Debugger Manual

sthx buffptr ; save index to data buffer
ldhx descptr ; is it last descriptor byte?
cphx descendptr
beq LAST_DESC
ldhx buffptr ; is data buffer filled?
cphx #8
beq DATAFILLED ; go send data
bra IN_SEND_DATA ; else continue

LAST_DESC:
clr control ; if so then end of data transfer
DATAFILLED:
lda buffptr+1 ; set the size of the buffer
asla ; shift to upper nibble
asla
asla
asla
ora #$08 ; set DVALID_IN bit that data is ready
sta UEP0CSR
rts

IN_PROC2:
bclr 2,UEP0CSR ; clear the TFRC_IN bit for further
packets
rts

****************************************************************
* OUT_PROC - This procedure handles the OUT packets that are *
* sent by the USB peripheral through endpoint 0. *
****************************************************************
OUT_PROC:
lda UEP0CSR ; setup endpoint 0 for more packets
and #$fc ; all OUT packets received for endpoint 0
sta UEP0CSR ; should be for status stage of requests
rts

**************************************************************
* MAIN_INIT - This is the point where code starts executing *
* after a RESET. *
**************************************************************
MAIN_INIT:
rsp
clra
clrx
mov #$01,CONFIG ; URSTD=1 (USB reset=interrupt),
; disable COP watchdog
mov #$FF,PULLCR ; enable pullups for port B
jsr Init_USB ; Initialize USB peripheral

Advertising