PIC16C745/P Microchip Technology, PIC16C745/P Datasheet - Page 73

no-image

PIC16C745/P

Manufacturer Part Number
PIC16C745/P
Description
8-Bit CMOS Microcontrollers with USB
Manufacturer
Microchip Technology
Datasheet
SET_CONFIGURATION command. Once the device
is configured, the application can communicate with
the host using the GetUSB and PutUSB calls.
The USB peripheral detects several different errors
and handles most internally. The USB_ERR interrupt
notifies the microcontroller that an error has occurred.
No action is required by the device when an error
occurs. Instead the errors are simply acknowledged
and counted.
device off the bus if there are too many errors. If this
behavior is desired it must be implemented in the
application.
The Activity interrupt is left disabled until the USB
peripheral detects no bus activity for 3 mS. Then it
suspends the USB peripheral and enables the activity
interrupt. The activity interrupt then reactivates the
USB peripheral when bus activity resumes so process-
ing may continue.
; ******************************************************************
; Demo program that initializes the USB peripheral, allows the Host
;
; ******************************************************************
main
idleloop
CheckEP1
PutBuffer
1999 Microchip Technology Inc.
to Enumerate, then copies buffers from EP1OUT to EP1IN.
call
ConfiguredUSB
call
bcf
movlw
movwf
movlw
call
btfss
goto
bcf
movwf
movlw
movwf
swapf
iorlw
call
btfss
goto
goto
end
There is no mechanism to pull the
InitUSB
CheckSleep
STATUS,IRP
buffer
FSR
1
GetUSB
STATUS,C
idleloop
STATUS,IRP
bufferlen
buffer
FSR
bufferlen,w
1
PutUSB
STATUS,C
PutBuffer
idleloop
; Set up everything so we can enumerate
; wait here until we have enumerated.
; Ok, here’s a good point to put part to sleep if no activity on the bus.
; Check Endpoint 1 for an OUT transaction
; point to lower banks
; point FSR to our buffer
; check end point 1
; If data is ready, it will be copied.
; was there any data for us?
; Nope, check again.
; point to lower banks
; save buffer length
; point FSR to our buffer
; upper nybble of W is buffer length
; lower nybble of W is EndPoint number
; was it successful?
; No: try again until successful
; Yes: restart loop
Advanced Information
CheckSleep is a separate call that takes the bus idle
one step further and puts the device to sleep if the
USB peripheral has detected no activity on the bus.
This powers down most of the device to minimal cur-
rent draw. This call should be made at a point in the
main loop where all other processing is complete.
10.9.6
This example shows how the USB functions are used.
This example first initializes the USB peripheral which
allows the host to enumerate the device. The enumer-
ation process occurs in the background, via an Inter-
rupt service routine.
enumeration is complete, and then polls EP1 OUT to
see if there is any data available. When a buffer is
available, it is copied to the IN buffer. Presumably your
application would do something more interesting with
the data than this example.
EXAMPLES
PIC16C745/765
This function waits until
DS41124A-page 73

Related parts for PIC16C745/P