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

USB Newbie needs starting guidelines

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



Joined: 17 Jan 2006
Posts: 66

View user's profile Send private message

USB Newbie needs starting guidelines
PostPosted: Wed Feb 25, 2009 6:10 am     Reply with quote

Hi all,
Although I have been working with PICs for a long time, I have to use the USB capabilities of a PIC18 MCU for the first time in a new project.
At first I thought it would be as simple as the RS232 interface (adding a #use USB or similar and let's go) but after some days reading about this issue... I'm completely messed up and lost.
The PC software I have to comunicate with will be using the HID interface but we are going to develop our own protocol, data frames, etc.
I have no idea about how to begin to develop this code.
Do I need to define USB descriptors?
Can I avoid making this considering is a custom made application?
Where can I find a whole project example, not just the main c file?
I'm completely lost about how to begin this project and my boss is getting angry :S
Any help or guideline beyong the CCS examples will be welcome (or even a explanation about how to understand these)
Thanks a lot,

Juanma
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Feb 25, 2009 7:20 am     Reply with quote

Quote:
Any help or guideline beyond the CCS examples will be welcome.


Well, i think it's advisable to go into the examples before going beyond them. This involves spending some time evaluating an experimental setup of a development board (respectively your target board) and a PC. To my opinion, it wouldn't make much sense to give explanations of the examples before you seriously tried to use them.

As another point, you have to define your application requirements. You just stated, you want to develop your own protocol, which can mean a lot or nearly nothing. A basic decision is about using a protocol supported by generic drivers as CDC or HID, write your own Windows Kernel drivers in MS DDK, or use one of the available WinDriver like tools. For a decision, you should learn about the capabilities and limits of the said generic USB drivers and the effort of writing your own one. For standard applications, that don't require a throughput up to the limited, CDC is a good choice, I think (HID probably too, but I didn't use it yet).
Neckruin



Joined: 17 Jan 2006
Posts: 66

View user's profile Send private message

PostPosted: Wed Feb 25, 2009 11:05 am     Reply with quote

I have spent some time trying to understand the CCS examples, but it seems to me that they are made supposing a high previous USB knowledge.
I just don't know even how many files are required for a USB project to be developed or similar basic issues.

I'll try to compile a .c example and post any errors or dificulties I find.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 25, 2009 2:08 pm     Reply with quote

If you try the HID demo program from CCS, here's a tip about the
Hiddemo.exe windows application:

It has a button called "Establish Connection". But if press it, you will
get an error message, saying that the device is not selected.
To fix this, go to the "File" menu in the Hiddemo.exe program and click
on "Select Device". Then click on the CCS HID device in the list. Now
you can click on the "Establish Connection" button and it will work.
Then you can make the LEDs go on/off, etc.
Jim Hearne



Joined: 22 Dec 2003
Posts: 109
Location: West Sussex, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Feb 26, 2009 8:04 am     Reply with quote

Does your project have to have true USB on it or could you get away with using a USB to serial convertor on the project so you are talking to the pic via a familiar serial interface.
On the pc end there is a USB driver (supplied by the USB-Serial chip maker) so the pc software thinks it's talking to a serial port.

This is how the CCS USB programmers work, they are still the serial versions really with a USB to serial converter chip tacked onto them.

Jim
Neckruin



Joined: 17 Jan 2006
Posts: 66

View user's profile Send private message

PostPosted: Thu Feb 26, 2009 9:48 am     Reply with quote

Jim Hearne wrote:
Does your project have to have true USB on it or could you get away with using a USB to serial convertor on the project so you are talking to the pic via a familiar serial interface.
On the pc end there is a USB driver (supplied by the USB-Serial chip maker) so the pc software thinks it's talking to a serial port.

This is how the CCS USB programmers work, they are still the serial versions really with a USB to serial converter chip tacked onto them.

Jim


Really?
We didn't even consider that option.
Considering that, PICs with integrated USB would be useless :/
Anyway, it will be probably someone else's problem, because I have just meet my boss and has transfered me to another department.
Now I'll be an Onboard Equipment Engineer.
I'll go to google to see what the hell is that!! :D

Well, as I'll have to help the new engineer to begin with this, you will probably see me here asking about USB again.

Thank you and see you soon,

Juanma
Jim Hearne



Joined: 22 Dec 2003
Posts: 109
Location: West Sussex, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Feb 26, 2009 10:00 am     Reply with quote

Yup.
As long as you don't need the bandwidth of the proper usb it's a easy solution to making products USB compatible.


Look at the FTDI FT232 series of chips.
http://www.ftdichip.com/FTProducts.htm

Jim
Neckruin



Joined: 17 Jan 2006
Posts: 66

View user's profile Send private message

PostPosted: Thu Feb 26, 2009 11:13 am     Reply with quote

Thank you very much.
I'm already passing all this info to my partner who is going to work on the USB driver.
It can be a much faster way to solve this problem, at least from the low level software point of view.
I suppose the development will also be easier from the high level sw pov.
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Thu Feb 26, 2009 12:42 pm     Reply with quote

I've used the USB interface chips from FTDI, and I can report that they're easy to use at both ends of the cable. As has been said, as far as programming at the PC end is concerned, it looks like a serial port, and at the processor end, you talk to it via the UART. The one odd feature (maybe if I weren't such a USB newbie myself, I wouldn't call it odd) is that the number of the serial port is dependent on the individual chip you use, i.e. each one will get assigned a unique number and it increases with each new device you plug in. I think there's a way to defeat this feature, but so far I haven't needed to find it. But you do have to have software that can find a serial port that has almost any number. Is 255 the max? I think it is.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Feb 26, 2009 1:01 pm     Reply with quote

If you have a dedicated apllication at the PC side and don't need the virtual COM port feature, it's suitable to use the FTD2XX.DLL interface instead. It's also considerably faster and you have more options to enumerate individual adapters. Most existing solutions go this way, e.g. CCS ICD-U40.

When using VCOM interface, you can ease device selection by accessing windows registry information and avoid searching for unknown COM port numbers.
Neckruin



Joined: 17 Jan 2006
Posts: 66

View user's profile Send private message

PostPosted: Fri Feb 27, 2009 1:52 am     Reply with quote

Thank you guys,
This is all very interesting.
I hope is not too late to consider the hardware design changes this would involve.
We had already selected a PIC18F87J50 mcu, which is not easy to work with (at least for me).
By using an FTDI device we could select another PIC.
I'll have to talk with the hardware engineer.
Thanks again.

Juanma
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