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

C sharp and pic usb interfacing in ccs compiler

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



Joined: 22 Oct 2005
Posts: 20

View user's profile Send private message

C sharp and pic usb interfacing in ccs compiler
PostPosted: Mon Nov 12, 2007 10:13 pm     Reply with quote

aoa.
I want convert a serial port based project to usb.
It has a PC interface, lcd,analog inputs, 4 switches, 4 leds.
I want to use c sharp 2K5 for interface and CCS compiler for PicUsb
Programming. In start i want to do >
1. read one analog channel.
2. Check 1 Button status.
3. Send some data to lcd
4. Update status of one led.
Now i have following questions.
1. which type of transfer to use?
2. Which class i need to use?
3. What is the relation between transfer type and class.
4. Can i use "mpusbapi.dll" for interfacing pic or i need my own driver?
5. Why "Communication Devices Class" examples emulate Serial Port.
6. If i use CDC, which driver i need.

If any body has any sample code in c sharp and ccs compiler then please help me. I have seen some examples but some has c sharp code with microchip compiler and some examples has demo.exe with out source code. I use ccs compiler and i need code in c sharp and ccs only.

Thanks for ur look at this post.
Have a nice day.
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Tue Nov 13, 2007 4:20 am     Reply with quote

check this out:
http://www.piccoder.co.uk/content/view/42/26/

As for CDC: it is quite simple way how to use the USB. For CCS CDC example, you should use cdc_NTXP.inf located in Drivers directory
davekelly



Joined: 04 Oct 2006
Posts: 53
Location: Berkshire, England

View user's profile Send private message

PostPosted: Wed Nov 14, 2007 10:11 am     Reply with quote

I have just been working on a similar exercise of using USB interfaces instead of serial comms, with c# on the PC side.

The CDC model is by far the easiest as pointed out by meereck.

During debugging though, whichever model you use is a nightmare, as using breakpoints mean you lose the USB interface with the PC as soon as a breakpoint is reached, or you have any bugs/lockups in your firmware code.

For my project I am taking the easy way out, and using a FTDI232 IC to do all the USB handling instead.

The c# side is easy, just use the serialport component from .NET 2.0 or later. Using any other USB model (eg HID) though is difficult, and takes a lot of code to get the comms working.
mrpicing



Joined: 22 Oct 2005
Posts: 20

View user's profile Send private message

PostPosted: Wed Nov 14, 2007 11:44 pm     Reply with quote

aoa.
Thanks 4 ur kind reply.
As meereck Smile directed me to piccoder. i've already seen it.
It is very good example but it has microchip code. I need CCS code.
Thanks davekelly 4 ur advice but i want to use pic rather then usbchips
because I want to do some other project on PIC18F4550.
So i want to use pic. I have poor grip on VC# but will try to use
"mpusbapi.dll" or will ask my friends to write usbcdc code for me.
Currently i've started to use pic as custome HID device.I dont know "mpusbapi.dll" supports HID or not but see u after some time with more details.
Once again Thanks 4ur replies Smile .
Sorry for any mistake.
Have a nice day! Very Happy
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Thu Nov 15, 2007 2:25 pm     Reply with quote

All right, finally, I have found it.
This is an example for CCS C Compiler together with VS2005 C#, which is probably what you are looking for.
http://www.hobbypic.com/index.php?option=com_content&task=view&id=14&Itemid=27
http://www.hobbypic.com/index.php?option=com_content&task=view&id=23&Itemid=27

But anyway, if you dont want to do so much coding, as davekelly wrote, just use the CDC which behaves like common serial port.
In VS2005, you can find a component for a serial port under Component toolbox>Components>SerialPort

good luck,
M.
mrpicing



Joined: 22 Oct 2005
Posts: 20

View user's profile Send private message

PostPosted: Fri Nov 16, 2007 12:32 am     Reply with quote

aoa.
Thanks a lot. I was really looking for this type of example.
I just managing to get csharp source code and driver api
of that application. See u later with next picing...
Keep Picing...
Thanks once again.
Have a nice day.
Bill Ewing



Joined: 22 Apr 2008
Posts: 1

View user's profile Send private message

PostPosted: Tue Apr 22, 2008 10:42 am     Reply with quote

If you're still looking for help, please let me know and I'll share what I've got.

Or you can try taking the same path I did, and I would hope you experience less pain.

I started at Jan Axelson's website: http://www.lvr.com/

She wrote THE book on USB: "USB Complete". You might want to buy that, but be prepared for some pretty dense reading. Still, it is way easier than trying to digest the monstrously large USB spec.

Having already done CDC with Microchip's code, I wanted to do HID instead, so I found the C# app here:
http://www.lvr.com/hidpage.htm#MyExampleCode

I didn't care much for that app because it was full of stuff I didn't need, such as compatibility with Windows 98 Gold. It's a "kitchen sink" and probably contains a lot of stuff you don't want either. I managed to strip it down to just what I needed. I also changed it from exchanging a pair of bytes to a useful number (for my purposes) - up to 32. I'd be happy to share that, though I am not proud of it. Sadly, most sample code is pretty crappy to anyone who has high standards as far as object oriented programming goes. Maybe I'll be able tp improve that, but for now I was happy to just have something that works.

Next, like you, I wanted to go with the CCS compiler. Darren Rook seems to head up USB stuff at CCS (he taught the CCS class at the last Microchip Master's Conference). Darren is a really nice guy and sent me the code that comes with CCS' USB dev kit. With a little help from him, I hacked that into exchanging more than just two bytes. I'd be happy to share that.

BTW, the USB code Darren sent me was not available for free download. I believe Darren indicated that they were going to make that generally available rather than just provide it in the dev kit. This makes a lot of sense because that way we can get updates without hassling the folks at CCS. And besides, Microchip freely gives away their code for USB.

Also, BTW, I am using the 18F4553 instead of the 18F4550. It's virtually the same part except it has a 12-bit ADC. For anyone using that and wanting all 12 bits, be prepared to add this line:
#DEVICE ADC=12

I wish this story had a happy ending. Right now, I am struggling with a bug - perhaps it's in the compiler (at this time, I'm using the latest PCH v4.071) but when in doubt, blame yourself. When I add an interrupt service routine for timer0 (#define INT_RTCC) I can no longer set breakpoints- which needless to say makes debugging really #$@%&#! hard. If I take the ISR out, this problem goes away.

CCS seems to be working hard on this problem.

Unfortunately, I am running out of time having blown a whole week on this last issue alone. I am looking at changing all my code to using Microchip's 18F compiler. I used it successfully on a CDC project, so I'm pretty sure I can get this to work on it, but it would be sad to abandon CCS since I use them on all kinds of other parts including 10F, 12F and 16F types and that's the beauty of CCS- being able to migrate across and between component families. But then, what I might end up with is an an abstraction layer that allows me to use either Microchip or CCS (once we figure this bug out).
Will
Guest







I need it!
PostPosted: Wed Jul 23, 2008 6:22 pm     Reply with quote

Hello Bill.

I am looking for a solutions using USB through CCS.

Can you show me the development kit code that you were given?

Or perhaps just help me out. I haven't found any material that shows how to make USB work with CCS.


Thank you!
mrpicing



Joined: 22 Oct 2005
Posts: 20

View user's profile Send private message

PostPosted: Wed Jul 23, 2008 8:38 pm     Reply with quote

hi there
I posted this thread, but after seeing replies i searched more...
after searching a lot of time i found a thai web site it contained some project for pic usb. that guy done a great work for beginners.
Try " jnut thailand " in google. i downloaded complete source code and every thing of that project. i tried it on proteus it was running.
I also tried my own code based on jnut code. It worked on proteus.
Try it. I think it will help u.
Have a nice day
Guest








PostPosted: Wed Jul 23, 2008 9:41 pm     Reply with quote

Hey Will,
I started using Microchip's PIC DEM FS USB demo board because it did USB. It has a PIC18F4550 on it. I initially laid out my own daughter PC board to plug into its header to extend its I/O. That was kinda klugey so I relaid out everything into one board.

I talked today to Darren Rook, the guy who wrote the CCS USB code and he assured me that they have it working well. I like CCS for the same reasons everybody else does, so I hope to get back to using their compiler for USB stuff. (I use it now for 10F and 12F projects, and the ability to migrate up and down the processor food chain is one of its big appeals).

Since you're at this forum, you probably like the CCS toolset, so I would recommend buying their demo board for USB and go from there.

Good luck,
Bill
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