Hi everyone, I have been experimenting with bitfogavs USB HID software but have been having trouble compiling the swordfish code (bitfogav, this ones for you)
I have downloaded and copied the latest USB HID files from the swordfish site to my swordfish library. I opened up your HID ver 2 code and clicked compile. This is what came up:
Any idea's as to what's going on here?
Help needed with bitfogavs USB HID.
Moderators: Chuckt, Garth, bitfogav
Re: Help needed with bitfogavs USB HID.
Im not sure if your question has already been answered at Digital-DIY but I would say its because the latest USB HID files on the Swordfish website are something that Jerry (jmessina at digital-diy) has put together and updated and the usual USB locations/names have been changed. I would suspect that the new USB files are conflicting with what should be the old USB version?.
My USB board and app was designed with only the original USB Swordfish files (versions 1.1) and not the updated USB files which are found here SF USB Version 1.4
I have just tested my app and the SF code for version 2, I have not linked the new USB files into Swordfish so I am still using the old 1.1 version and I did get a compile failure but that was because I have a missing included file "iHIDDesc.bas" I have just noticed that it is not included on the Digital DIY post, sorry thats my mistake.
Here is a working app and my usb board version 2: (note if you want to compile it with swordfish then I would remove the new USB files?) Swordfish Code:
My USB board and app was designed with only the original USB Swordfish files (versions 1.1) and not the updated USB files which are found here SF USB Version 1.4
I have just tested my app and the SF code for version 2, I have not linked the new USB files into Swordfish so I am still using the old 1.1 version and I did get a compile failure but that was because I have a missing included file "iHIDDesc.bas" I have just noticed that it is not included on the Digital DIY post, sorry thats my mistake.
Here is a working app and my usb board version 2: (note if you want to compile it with swordfish then I would remove the new USB files?) Swordfish Code:
Code: Select all
// device and clock...
Device = 18F2550
Clock = 48
// 20Mhz crystal, 48Mhz internal (FS USB)
Config
PLLDIV = 5, '}
CPUDIV = OSC1_PLL2, '} Set oscillator options to give 48MHz
USBDIV = 2, '} internal clock from 20MHz crystal
FOSC = HSPLL_HS, '}
VREGEN = ON '} Enable internal 3.3V regulator for USB
// this is the programs descriptor, generated by EasyHID - you
// can find it in the same folder as this program...
#option USB_DESCRIPTOR = "iHIDDesc.bas"
// uncomment this line when we are not using the HID module service mode
'#option USB_SERVICE = False 'USB not automatically serviced - call
'HID.Service every 1mS
// import the HID and other used modules...
Include "usbhid.bas"
Include "USART.bas"
Include "convert.bas"
Dim BufferOut(32) As Byte Absolute TXReportRAM
Dim BufferIn(32) As Byte Absolute RXReportRAM
Dim i As Byte
Dim button1 As PORTC.0
Dim button2 As PORTC.1
Dim button_debounce As Word // button debounce
Dim led1 As PORTB.0
Dim led2 As PORTB.1
Dim led3 As PORTB.2
Dim led4 As PORTB.3
Dim button_one As Boolean
Dim button_two As Boolean
// Subroutins and Functions
Sub checkleds() // test to check all leds on start-up (power on)
Dim i As Byte
For i = 0 To 3
PORTB.Bits(i) = 1
DelayMS(50)
PORTB.Bits(i) = 0
DelayMS(50)
Next
End Sub
Sub debounce_buttons() // debounce all buttons
If button_debounce <> 0 Then
Dec(button_debounce)
EndIf
End Sub
Sub sendBufferData() // send USB buffer (bufferOut)
For i = 0 To Bound(BufferOut)
BufferOut(i) = i
Next
If button_one = true Then // check button1 settings
BufferOut(6) = 100
Else
BufferOut(6) = 0
EndIf
If button_two = true Then // check button2 settings
BufferOut(7) = 100
Else
BufferOut(7) = 0
EndIf
// send report
HID.WriteArray(BufferOut,32) // Write an array of bytes
End Sub
// setup USART (avoid using pickit usart as it slows down comms to pc - crashs VB app)
SetBaudrate(br115200) // Usart baud rate..
'SetBaudrate(br38400) // for Pickit2 uart tool.. this is the max baud rate for pickit2
Output(led1)
Output(led2)
Output(led3)
Output(led4)
// Init Variables
BufferOut(6) = 0
BufferOut(7) = 0
button_one = false
button_two = false
button_debounce = 200
checkleds
// main program loop
While True
// connect to USB...
Repeat
Until Attached
While Attached
// check for new report
If HID.DataAvailable Then
HID.ReadReport // Read a HID report into RXReport buffer
EndIf
// Remeber BufferOut(0) always equl 0 - physical data starts from BufferIn(1)
If button1 = 0 And button_debounce = 0 And button_one = false Then
button_one = true
button_debounce = 50000 // debounce our button, it is high due to clock speed.
sendBufferData
ElseIf button1 = 0 And button_debounce = 0 And button_one = true Then
button_one = false
button_debounce = 50000 // debounce our button, it is high due to clock speed.
sendBufferData
EndIf
// Remeber BufferOut(0) always equl 0 - physical data starts from BufferIn(1)
If button2 = 0 And button_debounce = 0 And button_two = false Then
button_two = true
button_debounce = 50000 // debounce our button, it is high due to clock speed.
sendBufferData
ElseIf button2 = 0 And button_debounce = 0 And button_two = true Then
button_two = false
button_debounce = 50000 // debounce our button, it is high due to clock speed.
sendBufferData
EndIf
// Led 1
If BufferIn(0) = 100 Then
High(led1)
Else
Low(led1)
EndIf
// Led 2
If BufferIn(1) = 100 Then
High(led2)
Else
Low(led2)
EndIf
// Led 3
If BufferIn(2) = 100 Then
High(led3)
Else
Low(led3)
EndIf
// Led 4
If BufferIn(3) = 100 Then
High(led4)
Else
Low(led4)
EndIf
debounce_buttons // calls Sub to debounce our buttons.
Wend
Wend
If you don't know what Voltage your country is using, you shouldn't be doing electronics
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Help needed with bitfogavs USB HID.
Thanks bitfogav - it was the new include files!
I don't know why I didn't think of that when I was wracking my brain for hours yesterday trying to figure it out...
I can now (once again) look forward to some awesome USB communications!
I don't know why I didn't think of that when I was wracking my brain for hours yesterday trying to figure it out...
I can now (once again) look forward to some awesome USB communications!
Who is online
Users browsing this forum: No registered users and 3 guests