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

USB communication to PC

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







USB communication to PC
PostPosted: Fri Jun 12, 2009 1:22 pm     Reply with quote

Hello everyone.

I need to make one VB Program which will send some commands to PIC.
My problem is that I have to use USB communication for data transfer.

I need to pass command like "start" and the respond to that should be that the motor would start to spin.

What do I need to do on the PC side and what on the PIC side to make this work ? How can PIC accept and process data that I pass from PC ?

Thank you for your time.
Ttelmah
Guest







PostPosted: Fri Jun 12, 2009 2:59 pm     Reply with quote

Easiest way, is probably the CDC device class.
This is illustrated in the examples 'ex_usb_serial.c', and 'ex_usb_serial2.c'. These contain the code to first just echo data back, and the second to allow you to change a memory location, using serial commands. This class, implements basically, a USB 'emulation', of a simple serial port. Seen by the system as 'COMx', and talkable from VB, using the MSCOMM control.
So, your VB program, would need to be told what com port the device is on (it is possible to actually search for the device by name, using the API, but this is more complex programming), and then open this port, and send the commands. The PIC code would be similar to ex_usb_serial2,but with a 'parser', looking for the commands you want to accept. A search here will find lots of parser examples, in particular for modem strings. Once the required string is seen, the output bits would then be changed to perform the required operation.

Best Wishes
JamesL
Guest







PostPosted: Sat Jun 13, 2009 3:41 am     Reply with quote

OK. Thank you for your suggestion.
To expand this question I would also like to define some main things when you are writing data to memory per USB.

I am using external memory and I would like to save some part of the encrypted data that I pass from PC into external memory of my device.

What would be the smallest encrypted value that I can write into external memory ? What data type, what writing format ?
Ttelmah
Guest







PostPosted: Sat Jun 13, 2009 3:00 pm     Reply with quote

That is competely down to your code.
Assume (for example), that your external memory, accepts data in bytes. Then there is nothing to stop your code, reading a byte, modifying one bit, and writing it back. Just as with the #bit, and #byte commands in CCS C itself, it is then down to your parser implementing instructions to access individual bits. So you could have (for example), a 'read_byte' command, and a 'read_bit' command, with the former just having a byte address number, and the latter having a bit number as well. The same applies with writes.

Best Wishes
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