PIC16C765 Microchip Technology Inc., PIC16C765 Datasheet - Page 75

no-image

PIC16C765

Manufacturer Part Number
PIC16C765
Description
8-bit Cmos Microcontrollers With Usb
Manufacturer
Microchip Technology Inc.
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
PIC16C765-I/L
Manufacturer:
Microchip Technology
Quantity:
10 000
Part Number:
PIC16C765-I/P
Manufacturer:
MICROCHIP
Quantity:
12 000
Part Number:
PIC16C765-I/PT
Manufacturer:
Microchip Technology
Quantity:
10 000
Part Number:
PIC16C765/JW
Manufacturer:
MIC
Quantity:
60
Part Number:
PIC16C765/JW
Manufacturer:
MIC
Quantity:
60
Part Number:
PIC16C765/JW
Manufacturer:
MIC
Quantity:
5
Part Number:
PIC16C765/JW
Manufacturer:
MICROCH
Quantity:
20 000
Part Number:
PIC16C765T-I/L
Manufacturer:
Microchip Technology
Quantity:
10 000
Part Number:
PIC16C765T-I/PT
Manufacturer:
Microchip Technology
Quantity:
10 000
10.9.7
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. This function waits until
; ******************************************************************
; Demo program that initializes the USB peripheral, allows the Host
;
; ******************************************************************
main
CheckEP1
; Code host to process out buffer from host
PutBuffer
10.9.8
The code is designed to be used with the linker. There
is no provision for includable files. The code comes
packaged as several different files:
• USB_CH9.ASM - handles all the Chapter 9 com-
• USB_DEFS.INC - #Defines used throughout the
• USB_MAIN.ASM - Sample interrupt service
• HIDCLASS.ASM - Handles the HID class specific
2000 Microchip Technology Inc.
mand processing.
code.
routine.
commands.
call
ConfiguredUSB
bankisel buffer
movlw
movwf
movlw
call
btfss
goto
bankisel buffer
movlw
movwf
movlw
call
btfss
goto
goto
end
to Enumerate, then copies buffers from EP1OUT to EP1IN.
EXAMPLE
ASSEMBLING THE CODE
InitUSB
buffer
FSR
1
GetUSB
STATUS,C
PutBuffer
buffer
FSR
0x81
PutUSB
STATUS,C
PutBuffer
idleloop
; Check Endpoint 1 for an OUT transaction
; Set up everything so we can enumerate
; wait here until we have enumerated.
; 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
; put 8 bytes to Endpoint 1
; was it successful?
; No: try again until successful
; Yes: restart loop
Preliminary
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.
10.9.8.1
There are two #defines at the top of the code that con-
trol assembly options.
10.9.8.2
This define includes code to count the number of
errors that occur, by type of error. This requires extra
code and RAM locations to implement the counters.
10.9.8.3
This is useful for debug. It encodes the upper 6 bits of
USWSTAT (0x197) to indicate which function is exe-
cuting. See the defines in USB_DEFS.INC for the
codes that will be encoded.
Assembly Options
#define ERRORCOUNTERS
#define FUNCTIONIDS
PIC16C745/765
DS41124C-page 75

Related parts for PIC16C765