Hardware Reference
In-Depth Information
*
reception of a SETUP transaction.
*
Firmware work-around is implemented below.
*/
0015c0
a070
BTFSS
0x70,0x0,0x0
if(UEP0bits.EPSTALL == 1)
0015c2
d003
BRA
0x15ca
{
0015c4
ec8b
CALL
0x1316,0x0
USBPrepareForNextSetupTrf();
// Firmware Work-Around
0015c6
f009
0015c8
9070
BCF
0x70,0x0,0x0
UEP0bits.EPSTALL = 0;
}
0015ca
9a68
BCF
0x68,0x5,0x0
UIRbits.STALLIF = 0;
0015cc
0012
RETURN
0x0
}
//end USBStallHandler
Für die Firmware der Beispielanwendung in diesem Buch muss daher der STALL
Interrupt der USB-Schnittstelle aktiviert werden, denn wie bereits erwähnt, läuft im
Beispiel alles per Interruptsteuerung. Sofern ein STALL Interrupt detektiert wurde,
läuft folgendes Programmsegment ab:
; this is an USB stall interrupt
HighIntStall
bcf
UIR,STALLIF
call
USBStallInterrupt
bra
fast_end
Wenn ein STALL Interrupt generiert wurde, muss im Interrupt-Behandlungspro-
gramm (Interrupt Service Routine, kurz: ISR) ermittelt werden, ob ein STALL des
Control Endpoint zum Interrupt geführt hat. Wenn ja, müssen beide Teile, also
Control OUT- und Control IN-Teil, des bidirektionalen Endpoints wieder in den
Normalbetrieb gebracht werden, so wie es im obigen Beispiel auch getan wird. Für
das Beispielprogramm in diesem Buch sieht das folgendermaßen aus:
;******************************************************************************
; USB Stall Interrupt Service Routine
;******************************************************************************
; this has to be done, because the control endpoint doesn't always accept
; a new SETUP token automatically
USBStallInterrupt
btfsc UEP0,0x00
bra
StallTrap
return
StallTrap
; return ownership of control OUT endpoint to SIE
movlw 0x00
movwf FSR0L
movlw 0x04
movwf FSR0H
movlw 0x80 ;10000000
;turn ownership to SIE
Search WWH ::




Custom Search