I purchased the Oshnsoft PIC16 software for USB.
The sample is as follows:
Define CLOCK_FREQUENCY = 16
Define CONFIG1 = 0x0f84
Define CONFIG2 = 0x1def
OSCCON = 0x3c 'intosc=16mhz
UsbSetVendorId 0x1234
UsbSetProductId 0x1234
UsbSetVersionNumber 0x1122
UsbSetManufacturerString "OshonSoft.com"
UsbSetProductString "Generic USB HID Device"
UsbSetSerialNumberString "1111111111"
UsbOnIoInGosub usbonioin
UsbOnIoOutGosub usbonioout
UsbOnFtInGosub usbonftin
UsbOnFtOutGosub usbonftout
AllDigital
ANSELA.4 = 1
TRISC = 0
PORTC = 0xff
UsbStart
PORTC = 0
Dim an3 As Byte
loop:
Adcin 3, an3
If an3 < 50 Then
PORTC = 0
UsbStop
While an3 < 100
Adcin 3, an3
Wend
PORTC = 0xff
UsbStart
PORTC = 0
Endif
UsbService
Goto loop
End
usbonftout:
Toggle PORTC.0
Return
usbonftin:
UsbFtBuffer(0) = UsbFtBuffer(0) - 1
UsbFtBuffer(1) = UsbFtBuffer(1) - 1
UsbFtBuffer(2) = UsbFtBuffer(2) - 1
UsbFtBuffer(3) = UsbFtBuffer(3) - 1
UsbFtBuffer(4) = UsbFtBuffer(4) - 1
UsbFtBuffer(5) = UsbFtBuffer(5) - 1
UsbFtBuffer(6) = UsbFtBuffer(6) - 1
UsbFtBuffer(7) = UsbFtBuffer(7) - 1
Return
usbonioout:
Toggle PORTC.1
Return
usbonioin:
UsbIoBuffer(0) = UsbIoBuffer(0) + 1
UsbIoBuffer(1) = UsbIoBuffer(1) + 1
UsbIoBuffer(2) = UsbIoBuffer(2) + 1
UsbIoBuffer(3) = UsbIoBuffer(3) + 1
UsbIoBuffer(4) = UsbIoBuffer(4) + 1
UsbIoBuffer(5) = UsbIoBuffer(5) + 1
UsbIoBuffer(6) = UsbIoBuffer(6) + 1
UsbIoBuffer(7) = UsbIoBuffer(7) + 1
Return
I am having some trouble with the logic.
When the program runs, it cycles through the loop statement.
I do not understand how to get data to and from the PC.
It looks like these statements get used only once at the beginning
UsbOnIoInGosub usbonioin
UsbOnIoOutGosub usbonioout
UsbOnFtInGosub usbonftin
UsbOnFtOutGosub usbonftout
I see that USB start and service are in the main loop. However, I do not seem to understand the logic.
It looks like
UsbOnIoOutGosub usbonioout
will call the usbonioout subroutine and what is ever in the subroutine will pass out of the USB port?
If that is the case, can I pass more than a bit through the USB port?
I am using PIC16F1459.
Would someone please provide an explanation of the logic?
Thank you.
The sample is as follows:
Define CLOCK_FREQUENCY = 16
Define CONFIG1 = 0x0f84
Define CONFIG2 = 0x1def
OSCCON = 0x3c 'intosc=16mhz
UsbSetVendorId 0x1234
UsbSetProductId 0x1234
UsbSetVersionNumber 0x1122
UsbSetManufacturerString "OshonSoft.com"
UsbSetProductString "Generic USB HID Device"
UsbSetSerialNumberString "1111111111"
UsbOnIoInGosub usbonioin
UsbOnIoOutGosub usbonioout
UsbOnFtInGosub usbonftin
UsbOnFtOutGosub usbonftout
AllDigital
ANSELA.4 = 1
TRISC = 0
PORTC = 0xff
UsbStart
PORTC = 0
Dim an3 As Byte
loop:
Adcin 3, an3
If an3 < 50 Then
PORTC = 0
UsbStop
While an3 < 100
Adcin 3, an3
Wend
PORTC = 0xff
UsbStart
PORTC = 0
Endif
UsbService
Goto loop
End
usbonftout:
Toggle PORTC.0
Return
usbonftin:
UsbFtBuffer(0) = UsbFtBuffer(0) - 1
UsbFtBuffer(1) = UsbFtBuffer(1) - 1
UsbFtBuffer(2) = UsbFtBuffer(2) - 1
UsbFtBuffer(3) = UsbFtBuffer(3) - 1
UsbFtBuffer(4) = UsbFtBuffer(4) - 1
UsbFtBuffer(5) = UsbFtBuffer(5) - 1
UsbFtBuffer(6) = UsbFtBuffer(6) - 1
UsbFtBuffer(7) = UsbFtBuffer(7) - 1
Return
usbonioout:
Toggle PORTC.1
Return
usbonioin:
UsbIoBuffer(0) = UsbIoBuffer(0) + 1
UsbIoBuffer(1) = UsbIoBuffer(1) + 1
UsbIoBuffer(2) = UsbIoBuffer(2) + 1
UsbIoBuffer(3) = UsbIoBuffer(3) + 1
UsbIoBuffer(4) = UsbIoBuffer(4) + 1
UsbIoBuffer(5) = UsbIoBuffer(5) + 1
UsbIoBuffer(6) = UsbIoBuffer(6) + 1
UsbIoBuffer(7) = UsbIoBuffer(7) + 1
Return
I am having some trouble with the logic.
When the program runs, it cycles through the loop statement.
I do not understand how to get data to and from the PC.
It looks like these statements get used only once at the beginning
UsbOnIoInGosub usbonioin
UsbOnIoOutGosub usbonioout
UsbOnFtInGosub usbonftin
UsbOnFtOutGosub usbonftout
I see that USB start and service are in the main loop. However, I do not seem to understand the logic.
It looks like
UsbOnIoOutGosub usbonioout
will call the usbonioout subroutine and what is ever in the subroutine will pass out of the USB port?
If that is the case, can I pass more than a bit through the USB port?
I am using PIC16F1459.
Would someone please provide an explanation of the logic?
Thank you.