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

[request] 18f series usb programming

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



Joined: 05 Feb 2016
Posts: 33

View user's profile Send private message

[request] 18f series usb programming
PostPosted: Tue Apr 19, 2016 11:30 am     Reply with quote

Hello everyone,

I am a new 18f series programmer. Before, i worked with 16f877 for a few months and i know the bulk of its properties.

Considering it, is there anyone who suggests me something about how can i learn usb programming? How should i start? I don't have any idea and just i have started reading the usb section in datasheet of 18f4550.

Thanks.
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Apr 19, 2016 2:10 pm     Reply with quote

well CCS kindly supplies a few 'drivers' and WORKING USb example programs....
That's where I started. Just be sure your PIC does a 1HZ LED program properly before you try anything more complicated! The 4550 NEEDS the correct fuses set AND the proper crystal to get USB to run!

Jay
biomed12



Joined: 05 Feb 2016
Posts: 33

View user's profile Send private message

PostPosted: Wed Apr 20, 2016 4:43 am     Reply with quote

temtronic wrote:
well CCS kindly supplies a few 'drivers' and WORKING USb example programs....
That's where I started. Just be sure your PIC does a 1HZ LED program properly before you try anything more complicated! The 4550 NEEDS the correct fuses set AND the proper crystal to get USB to run!

Jay


Ok, Thanks very much but i didn't want like that. I am a bit strange usb programming and i am looking for something like complete instructions or flowchart. How does the module work? The datasheet just telling registers. For instances, there are lots of documents to program uart module. In ccs manual, there are just codes for using to program the module. I hope, i could tell what i look for.

Thanks.
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 20, 2016 4:53 am     Reply with quote

If you want a book, buy Jan's! It's about 600+ pages long, dull and dreary AND goto the official USB.org website. Of course, goto Microchip and download every apnote they have on USB.
Do all that and you won't be back here for 3 or 4 months ! Lots of reading !! USB is very complicated and I wager 99% of those tech/engs that design with it don't KNOW 1% of what's really going on with it!!

I do know the CCS supplied drivers do work but if you need to know HOW it works , you need to understand the PIC at machine code level.The majority coming here for 'USB' only want it to work,don't care how it works.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Wed Apr 20, 2016 5:11 am     Reply with quote

Seriously, USB is complex.
You need to pull the document from the USB committee "Universal serial bus specification Version 2.00".
Then get one of the books like Jan Axelson's "USB complete".
It is not a 'you send something' type bus. The bus itself is running continuously and talking to all the devices. The master initiates all transactions (though certain slaves have the 'concept' of being able to initiate a transaction, this is actually done when the master polls them).
The slave device _has_ to have code to identify when it receives a packet addressed to it, and when a packet it wants to send has been read. The CCS drivers do all of this for you (except handling things like mass storage device transmissions). However the 'hooks' to attach your own code for things like this are in the CCS drivers.
Look at the comments inside the CCS drivers as well. These are a large part of the documentation.
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Wed Apr 20, 2016 8:30 am     Reply with quote

Joke is I see Temtronic said exactly the same thing while I was typing!.

It is worth understanding, that even on the PC master, or any other slave device, you would never write the complete USB code yourself, unless you have several months to spend.
I've tweaked, and even re-written the CCS code for some special applications (things like a PIC18, that is both a CDC, and MSD device), but would still not consider writing from scratch for USB. The best way is to understand the phases of the USB operation, and how the enumerators work (and what is needed at the PC end for each type of enumerator), then just modify the enumerator, and use the off the shelf routines.
Add to the list a USB monitor program that can watch the packets in both directions, or a logic analyser with similar abilities. I could not have got the MSD to work without one or the other of these.
biomed12



Joined: 05 Feb 2016
Posts: 33

View user's profile Send private message

PostPosted: Wed Apr 20, 2016 1:37 pm     Reply with quote

temtronic wrote:
If you want a book, buy Jan's! It's about 600+ pages long, dull and dreary AND goto the official USB.org website. Of course, goto Microchip and download every apnote they have on USB.
Do all that and you won't be back here for 3 or 4 months ! Lots of reading !! USB is very complicated and I wager 99% of those tech/engs that design with it don't KNOW 1% of what's really going on with it!!

I do know the CCS supplied drivers do work but if you need to know HOW it works , you need to understand the PIC at machine code level.The majority coming here for 'USB' only want it to work,don't care how it works.

Jay


Dear Jay, Why are you angry with me? Maybe i couldn't tell what i want. Of course, i won't produce usb from 'zero' again... JUST i didn't understand how it works via ccs c. Isn't this forum ccs? i expected from you to understand the question related with ccs. You could write me like..
1-) you need .. these files...
2-) then, use these codes for this..
3-) ... etc etc..

Because, there isn't complete task about it. Somebodies had shared codes also there are a lot of codes in the web, ok, BUT, there isn't any explanation to understand like a flowchat. For instance, Serial communication works like: a sender and a transmitter communicated with a baudrate.. you should use max232.. sender sends 8 bit datas.. etc etc..

I HOPE, I could tell this time..

THANKS
biomed12



Joined: 05 Feb 2016
Posts: 33

View user's profile Send private message

PostPosted: Wed Apr 20, 2016 1:50 pm     Reply with quote

Ttelmah wrote:
Seriously, USB is complex.
You need to pull the document from the USB committee "Universal serial bus specification Version 2.00".
Then get one of the books like Jan Axelson's "USB complete".
It is not a 'you send something' type bus. The bus itself is running continuously and talking to all the devices. The master initiates all transactions (though certain slaves have the 'concept' of being able to initiate a transaction, this is actually done when the master polls them).
The slave device _has_ to have code to identify when it receives a packet addressed to it, and when a packet it wants to send has been read. The CCS drivers do all of this for you (except handling things like mass storage device transmissions). However the 'hooks' to attach your own code for things like this are in the CCS drivers.
Look at the comments inside the CCS drivers as well. These are a large part of the documentation.


I had thought usb was smilar with serial communication. Thanks for information i am running on searching about it.

Thanks.
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Wed Apr 20, 2016 2:48 pm     Reply with quote

With USB, the cdc interface can _emulate_ normal serial operations (as far as the code is concerned), but this needs a huge amount 'behind the scenes'. The slave has to send a CDC descriptor to the CPU when enumerated, then on the PC this automatically loads the serial emulation driver at the PC end.
Then if (for instance) the PC sets the serial rate on such an emulated port, this has no effect at all on the usb rate. Instead a packet is sent to the driver at the slave end to say 'this is the baud rate I want to use', which it can use to set the rate for an external connection, or completely ignore!...

The host initiates all transactions. A slave cannot start sending stuff without being asked. All communications are 'half duplex' (only one way ata a time on the bus).

Do a search for AN57294, which is a really nice document from Cypress that gives a good starting description of USB. It is aimed at people wanting to understand the bus for their controllers, but is totally applicable to all devices.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 20, 2016 3:09 pm     Reply with quote

Also, look at the manual for the CCS USB Development kit:
http://silanus.fr/sin/formationISN/Robotique/Logiciels/CCS/Data%20Sheets/Development%20Kit%20for%20the%20USB%20Exercise%20Book.pdf
You could buy their board (as a standalone, instead of the whole
development kit), or you could build it.
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