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

Reading and writing to USB
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Pic_man
Guest







Reading and writing to USB
PostPosted: Mon May 04, 2009 3:27 am     Reply with quote

Greetings !

If someone can be so kind and explain me some basics of reading and writing from some USB stick to some PCB device with USB connector.

This USB PCB device will consist of flash memory and PIC24 chip with usb on to go. Flash will be used to store and process data, in the matter: save data, do something, send data to usb stick.

***************************************************
If i look at this throe typical example, than this would look like:
- insert USB stick into USB PCB reader
- read data from USB stick
- do something on USB PSB reader
- write data to external flash of USB PCB reader
- write new data to USB stick.
- disconnect.
**************************************************
Take this in consideration:
- data that should be written to USB: name/lastname/timestamp
- it will be streaming data.

-----------
I know that PIC can be described as USB slave so i need some additional "interface" between PIC and USB but for now i just want to understand the logic behind this.

Thank you!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon May 04, 2009 6:21 am     Reply with quote

Quote:
I know that PIC can be described as USB slave

No, USB OTG implies, that the PIC24 is acting as a host. Microchip has published a Reference Design USB Device - Mass Storage - SD Card reader within USB firmware framework v2.2, downloadable from microchip.com. There are no CCS C USB host examples yet available. Although the Microchip code is dedicated to C30, it should be possible to port it to PCD.
pic_man
Guest







PostPosted: Mon May 04, 2009 10:13 am     Reply with quote

Thank you for reply about the chip.
I understand you.

What about the first part of the question.
Is there some algorithm or some example how to make something like this?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon May 04, 2009 1:44 pm     Reply with quote

I just realized, that I copied the wrong Microchip project name. I meant USB Host - Mass Storage - Thumb Drive Data Logger.

Regarding your question, your asking for common actions of a Mass Storage Device Host. A far as I see, the Microchip example is doing similar things cause it implements a data logger, that can be controlled over a RS232 terminal interface.

But I didn't yet implement the PIC24 host function and I'm not aware of the effort involved with porting the C30 code. I recently ported some other Microchip code to PCD. From this experience, I thinks it's basically feasible.
Pic_man
Guest







PostPosted: Tue May 05, 2009 1:59 am     Reply with quote

Hi FVM.

PIC24 was set as easy solution but i dont think that this chip be implemented cuz there are cheaper versions. like 18F series...

Quote:
that can be controlled over a RS232 terminal interface

USB will be connected directly to chip.

What microchip example ?
Is there some ccs example that i can use as base.
HID example from CCS ?

Thank you.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue May 05, 2009 4:04 am     Reply with quote

It's not exavctly clear to me, what you're trying to achieve.

An USB-PIC18 can only act as a device ("Slave"), thus it can't access an USB memory stick, it can emulate an USB memory. CCS has no Mass Storage Device examples, as far as I know, for HID, see the CCS C examples directory.
Pic_man
Guest







PostPosted: Wed May 06, 2009 6:26 am     Reply with quote

Quote:
It's not exavctly clear to me, what you're trying to achieve


From the hardware side i have USB stick and pcb with USB connector
I have to make program that will communicate with usb stick on the way that i have described in the first post.

The only thing that i dont know , for now, is if i will use 18F or Pic24.
Regardless to chip, the program should do that what i have written..

Quote:

- insert USB stick into USB PCB reader
- read data from USB stick
- do something on USB PSB reader
- write data to external flash of USB PCB reader
- write new data to USB stick.
- disconnect.


Thank you !
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed May 06, 2009 9:08 am     Reply with quote

So everything is as said before:

Reading and writing to an USB memory stick doesn't work with a PIC18F.
Pic_man
Guest







PostPosted: Sun May 10, 2009 3:08 pm     Reply with quote

I will use PIC24.

- Is there some microchip example how to make what i have written?
- How to port c30 code to CCS C ?

Thank you for your time.
Regards.
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Mon May 11, 2009 6:42 am     Reply with quote

Apart from using a PIC24 and porting the Microchip Mass Storage Driver, there are a couple of other options. Disclaimer: I've only bookmarked these items - I've never used them! I have no idea how good they are:

Vinculum - A chip implementing a USB host, including mass storage, and serial.

GHI Electronics - They have a chip that supports USB mass storage, and SD cards.

DOSonCHIP - They have a chip that interfaces to SD cards, but not USB mass storage.

All these items should be usable with PIC18s as well as PIC24s. They might even work with PIC16s!
_________________
Andrew
Pic_man
Guest







PostPosted: Tue May 12, 2009 1:15 pm     Reply with quote

Hi Andrew and thank you for reply!
I will use PIC 24 because it has all that i need.

FVM has written that maybe there is a way to port USB example code from microchip to CCS.

If someone knows and wishes to make this, this would be of great use for all of us, because everyone will come to this situation where he will need PIC24 and USB.

Maybe, just setting some test or start program, which can be used in CCS ?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue May 12, 2009 1:53 pm     Reply with quote

Quote:
If someone knows and wishes to make this, this would be of great use for all of us

No doubt about it. Everybody loves others to do his work...

Personally, I don't wish to make this, at leat not now. Provided, the PIC24xxGB is basically able to operate as an OTG/mini host USB controller, PCD can be expected to manage it. It's a complex project however, e.g. usb_host.c has nearly 5k lines of code. It may be the case, that much of it can be ported rather smoothly, but not necessarily.

As a special point, I experienced every new third party code to reveal some new PCD bugs. Seriously, a careful but still optmistic effort estimation can't result in less than a week.

Thus the other options mentioned by andrewg also sound meaningful. Personally, I would opt for the PCD24 anyway, mostly a matter of taste. Vinculum possibly makes sense, if you can integrate an existing module as VDRIVE without start programming ofter another uP enviroment.
Pic_man
Guest







PostPosted: Tue May 12, 2009 11:51 pm     Reply with quote

Quote:
No doubt about it. Everybody loves others to do his work...


I was thinking, you would write something like this because this is the first though. I dont look at this on such way.
As you say it's quite complex project, specially for someone who didn't
do something like this.

Is there a way to make some main test program based on microchip example, or to give us some idea how to make this in CCS ?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed May 13, 2009 12:03 am     Reply with quote

I don't see a good way than actually porting the Microchip USB host code to CCS for trial.
PIC_man
Guest







PostPosted: Wed May 13, 2009 12:23 am     Reply with quote

Where can i download microchip code ?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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