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 CCS Technical Support

18F2550 usb connection to PC

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



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

18F2550 usb connection to PC
PostPosted: Tue Oct 30, 2012 7:12 am     Reply with quote

Hi! I want to connect 18F2550 to PC through usb. I saw there are few examples in the PICC/examples directory but I`m not sure which one appropriate. Can tell me which one to use??
One more thing: I want to to see on the PC the information which I`m sending - just to be sure everything is OK. What program should I use for that???
Thanks!
KT315



Joined: 27 Oct 2009
Posts: 19

View user's profile Send private message

PostPosted: Tue Oct 30, 2012 8:23 am     Reply with quote

If you need only data, the better variant is ex_usb_hid.
Your device wold be defined as standard and no drivers needed. But you'll need a bit more special software for your PC.
With ex_usb_serial you create a virtual com port. Simpler coding for computer.
Ttelmah



Joined: 11 Mar 2010
Posts: 19541

View user's profile Send private message

PostPosted: Tue Oct 30, 2012 8:31 am     Reply with quote

Not actually a simple question.
The key is to understand that USB is a transport medium, rather than a particular interface. It has a whole 'suite' of different 'hats' it can wear, and which one is needed depends on what you are connecting, what expects to 'use' this, how fast data needs to travel, how quick responses must be, etc. etc..
It is the presence of these different 'hats', which is why you can have devices as different as a hard disk, and a joystick, both on this same medium.

Now probably the interface most likely to be a starting point, assuming you don't want the final target to transfer lots of data, or to be for specific tasks (like keyboard, mouse, joystick etc..), is the 'cdc class'. In it's simplest form, it be seen by the PC, just like a serial port, and existing serial monitor programs, and software used to talk to these ports, can be used.
EX_USB_SERIAL.C
EX_USB_SERIAL2.C

These both use the installation file cdc_NTXPVista.inf, which is in a sub directory of the drivers folder, to install.

The former is a basic 'hello world' application, the latter allows you to read the chip's EEPROM, and set a location in this, using the USB.

Both can be 'driven' from the standard serial driver programs (Hyperterm, Siow, and Teraterm for example).

This is the simplest interface to get working, but if you need (for instance) to transfer very large amounts of data quickly, then one of the other 'hats' will be needed.

Best Wishes
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Wed Oct 31, 2012 2:13 am     Reply with quote

I`m trying with ex_usb_hid but I have a problem with usb_task(). The controller can`t pass through this function. I can see on the PC something is connected and the PC says device not recognised. My controller still stays in usb_task(). Should I have to send some data to the controller to pass this function??? I used a simple program:
Code:
void main(void)
{
usb_init_cs();
int p=0;

while (TRUE) {
    usb_task();
    if (usb_enumerated())
    {
      p++;
    }
}

}

Thanks!
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