EasyHid

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

EasyHid

Post by dmtulsa » Mon Jan 21, 2008 5:10 pm

I'm really new to SF and I'm having a problem with EasyHID

In the USBhid.bas there is not a reference to some of the code the easyhid creates such as:

TXReportRAM error identifier not declared
RXReportRAM same

ReadReport same
WriteReport same

These are listed in the Help file but don't show up in the code explorer under usbhid.

I have the full version of SF 2.0.2.0

Am I diong something wrong here?

Code: Select all


// device and clock...                                                                                                                                                                                                                                         
device = 18F2450
clock = 48
   
// 20Mhz crystal, 48Mhz internal (FS USB)
config
   PLLDIV = 5,
   CPUDIV = OSC1_PLL2,
   USBDIV = 2,
   FOSC = HSPLL_HS,
   VREGEN = ON

// this is the programs descriptor, generated by EasyHID - you
// can find it in the same folder as this program...
#option USB_DESCRIPTOR = "NotBustedDesc.bas"

// import the HID module...
include "usbhid.bas"

// an example TX report structure, which contains a message
// string and two word values - the variable TXReport will overlay
// the structure over the USB dual port RAM buffer...
structure TTXReport
   Message as string
   ValueA as word
   ValueB as word
end structure
dim TXReport as TTXReport absolute TXReportRAM  

// an example RX report structure, which contains some bit
// value and a configuration byte - the variable RXReport will overlay
// the structure over the USB dual port RAM buffer...
structure TRXReport
   LED0 as bit
   LED1 as bit
   Configuration as byte
end structure    
dim RXReport as TRXReport absolute RXReportRAM

// rather than using the above structures, you can read and write data
// directly into a buffer array - choose which method you prefer - examples
// are given in the main program block...
dim Buffer(32) as byte

// connect to USB...
repeat
until Attached

// the main program loop shows two different ways in which you can read and
// write HID data. The ReadReport() and WriteReport() techniques are very useful
// when sending and receiving highly structured data (for example, string, bits,
// words etc). If you just want to send and receive blocks of bytes, then
// ReadArray() and WriteArray() are probably more useful - you can of course
// use both ways!
while true
   
   // this is one way you can read some HID data...
   if DataAvailable then
      ReadReport
      // the data is now in our RX structure - for example, PORTD.0 = RXReport.LED0 etc...
      // Alternatively, you can access the buffer directly as an array. For example,
      // HID.RXReport(0), HID.RXReport(1)...
   endif

   // rather than using ReadReport(), as shown above, you can read data directly 
   // into a buffer array. For example,
   if DataAvailable then
      ReadArray(Buffer,10)
   endif

   // this is one way you can write some HID data...
   TXReport.Message = "Hello World"
   TXReport.ValueA = $1234
   TXReport.ValueB = $0000
   WriteReport
   
   // rather than using WriteReport(), as shown above, you can write data directly
   // into a buffer array. For example,
   Buffer(0) = 0
   Buffer(1) = 1
   WriteArray(Buffer,2)
wend

Thanks
Doug
Doug
kd5nwk

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Mon Jan 21, 2008 5:24 pm

I think I see the problem. The pic 18f 2450 may not have extended ram so I can't use type structures . Is this correct?

Doug
Doug
kd5nwk

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

HID & 18F2450

Post by dmtulsa » Mon Jan 21, 2008 8:31 pm

I got the USB to work with a 18F4550 but I can't get it to xmit or receive with a 18F2450. I do get the connect - disconnect

Code: Select all


Device = 18F2450 '18F4550 works ok
Clock = 48
   
// 20Mhz crystal, 48Mhz internal (FS USB)
Config
   PLLDIV = 5,
   CPUDIV = OSC1_PLL2,
   USBDIV = 2,
   FOSC = HSPLL_HS,
   VREGEN = ON

// this is the programs descriptor, generated by EasyHID - you
// can find it in the same folder as this program...
#option USB_DESCRIPTOR = "NotbustedDesc.bas"

// import the HID module...
Include "usbhid.bas"


Dim Buffer(16) As Byte
Dim cnt As Byte
cnt = 0
// connect to USB...
Repeat
Until Attached


While true
  
   If DataAvailable Then
      ReadArray(Buffer,16)
      If Buffer(1) = 1 Then
        High (PORTB.2)
      Else
        Low (PORTB.2)                   
      EndIf 
   EndIf
   inc (cnt)
   'Buffer(0) = 255'cnt
   Buffer(0) = cnt
   'Buffer(2) = 255'cnt
   
   WriteArray(Buffer,1)
   DelayMS(1000)

Wend
Any ideas?
Doug
kd5nwk

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Mon Jan 21, 2008 8:45 pm

BTW I'd use the 18F2455 but microchip doesn't make it in a QFN package so I must use the 18F2450.

EasyHID doesn't support this chip (at least not in its list) so what can I change / edit to make it work.

Thank you
Doug
Doug
kd5nwk

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Tue Jan 22, 2008 3:51 pm

From the manual:

Buffer (256) as byte

Some USB devices have large areas of USB dual port RAM (typically 18F2455, 18F2550, 18F4455 and 18F4550). This is a general purpose buffer which can be used for receiving or transmitting very large data blocks. Please note that this buffer is not available on devices that have limited dual port RAM. For example, the 18F2450 and 18F4450

So, since I can't pass Buffer in writeArray how do I send / receive data?

Thanks
Doug
Doug
kd5nwk

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Tue Jan 22, 2008 5:41 pm

BTW I tried using CDC with basically the same results. the 18f4550 is seen by windows and I can install the "Driver". The 18F2450 is seen as an unknown device and the driver can not be installed. :(
Doug
kd5nwk

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Tue Jan 22, 2008 5:51 pm

Hi Doug,

I'm replying so that you don't feel like you're being ignored!! I've tried the USB HID module on an 18F4550 successfully, but have not used a 18F2450, so can't offer much help I'm afraid... Anyway, welcome to the Swordfish forum.

Steve

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Tue Jan 22, 2008 6:52 pm

Thank you Steve I starting to think nobody was home here.

Yes the 4550 works great. Is has something to do with the ram and it looks like the CDC and HID files are not set up for 2450 or 4450

I may have to use a 4550 44 pin QFN but its a lot more chip than I need and its twice the size plus costs more. BIG difference when making 1000's of boards.

I may have to write all the USB stuff myself. If so I'll do it in MPLAB ASM.

Doug
Doug
kd5nwk

richardb
Posts: 310
Joined: Tue Oct 03, 2006 8:54 pm

Post by richardb » Tue Jan 22, 2008 11:07 pm

can't you use the 2550?

PS whats happened to David Barker i dont think he's posted anything since november?
Hmmm..

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Wed Jan 23, 2008 12:06 pm

The 2550 would be great but its too big in size. the 2450 is 4x4mm and the 4550 is 8x8mm in QFN pkg. the 2550 doesn't come in a QFN

Thanks for the idea.
Doug
Doug
kd5nwk

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Thu Jan 24, 2008 10:29 pm

Have a look at the 18f2450 they come in the tiny 6mm x 6mm 28-Lead QFN

dmtulsa
Posts: 40
Joined: Fri Dec 21, 2007 1:38 pm
Location: Tulsa,OK
Contact:

Post by dmtulsa » Fri Jan 25, 2008 11:42 am

Tim,

Thats what I've talking about, 18F2450 in a QFN. I can't get it to work with HID or CDC.

The 4550 works great, its a little bigger 8x8, and cost almost double so I really need to use th 2450 if possible.

Thank you
Doug
Doug
kd5nwk

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

Post by rmteo » Tue Apr 29, 2008 9:14 pm

Doug,

Did you ever get the 18F2450 to work with HID?

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Wed Apr 30, 2008 7:09 am

Horaaaay a question I can answer.

The Pic18f2450 will work now, I have tested it. Not sure what if the current version of the compiler will be the beta does.

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

Post by rmteo » Wed Apr 30, 2008 11:30 pm

Tim, I tried a 18F4450 and it did not work quite right. eg, the VendorID and ProductID show as "??????????".

With a 18F4550 the data displays correctly (both PIC's were tested using the same descriptor file).

Post Reply