CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

I'm new with usb i need help for hid

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lionking



Joined: 20 Dec 2008
Posts: 3

View user's profile Send private message

I'm new with usb i need help for hid
PostPosted: Fri Jan 30, 2009 7:26 pm     Reply with quote

Hi everyone,
I'm using pic18f2550 and I couldn't use and understand example files of USB. I want just simple HID code for 18f2550. I'm using Easy HID program for to create an interface software. Is this a good choice? Can anyone help me about HID or usage of examples for 18f2550? Thank you.
GregEigsti



Joined: 12 Jan 2008
Posts: 12

View user's profile Send private message

PostPosted: Sun Feb 01, 2009 2:19 am     Reply with quote

Have you looked at CCS' Examples\ex_usb_hid.c file? Thats probably the best place to start as it is compatible with the CCS compiler. I am not familiar with "Easy HID" but would guess that it might not generate code that is compatible with the CCS compiler. Non compatible code would probably be more of a heartache than just grokking through ex_usb_hid.c and making it work for yourself.

I'm feeling pretty fresh on this subject as I built a HID device with an 18F2550 yesterday. Started with ex_usb_hid.c and modified it accordingly. Please let me know what it is you are trying to achieve and further explain the problems that you are having. Its really pretty easy once you put your mind to it.

Why couldn't you use the the CCS example?
What CCS compiler version?
Have you considered a CDC USB device? (IMO easier to program for)

Some advice while its still fresh
- Copy ex_usb_hid.c to a new location where your project is. That way you can muck with it and if you mess it up you always have the original version to go back to. It also contains the basics of reading/writing/setup so its a good start for a HID project.
- Copy usb_desc_hid.h to your local project as well - chances are that you will be modifying it and you want the original version around for a backup. Remember to point your local project's ex_usb_hid.c (or whatever you are calling it) at your local project's usb_desc.hid.h Wink
- ex_usb_hid.c does not include the 18F2550 device header, so you will need to do that.
- You will need to update your #fuses statement for your particular hardware setup. I can give you limited help on this but there are some great folks here who really understand it all (as well as posts that cover it all). I used to understand it but then I slept. Since I am a hobbyist I just keep building the same project boards and using my working #fuses.
- There are gems to be found in the CCS docs and by grep'ing/findstr'ing the CCS code to see how they use it. In fact tonight I played with CCS' srand/rand implementation for the first time and by looking around understood things a bit better (how to get a unique number for srand).
- HID is weird in that you set up a packet size and even if you send less than your packet size number of bytes the packet is always of the size that you originally set up. This takes some getting used to; I'm just adding a "valid byte count" at the beginning of the packet.

Greg
lionking



Joined: 20 Dec 2008
Posts: 3

View user's profile Send private message

PostPosted: Sun Feb 01, 2009 1:01 pm     Reply with quote

I'm trying to do my first experiment with usb and I try to use example of CCS C but I didn't manage it with 18f2550. And I wanna change that code for ex. leds on or something like that. But I don't know how should I start. Thank you.
GregEigsti



Joined: 12 Jan 2008
Posts: 12

View user's profile Send private message

PostPosted: Sun Feb 01, 2009 3:10 pm     Reply with quote

Without knowing exactly what you have tried, more about your PIC hardware/setup and what your failures have been I cannot really help. Just not enough info.

Basically you want to do the following:
- Copy the CCS example code to a new location and make sure that you can build it.
- Start modifying your new project code; things to look for are making sure you include the correct device info header (18F2550) and updating your #fuses line to match your particular hardware setup. Also make sure that any I/O pins that your hardware uses matches what is in your project (e.g. buttons, LEDs', sensors, etc.)
- Build your project and load it onto your PIC
- Run the PIC and connect it to the computer
- Run the PC side example software...

Greg
lionking



Joined: 20 Dec 2008
Posts: 3

View user's profile Send private message

PostPosted: Sun Feb 01, 2009 4:12 pm     Reply with quote

thank you very much my friend i'll try that
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group