Page 1 of 2

USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:04
by constructor
Hello everyone,

I'm new in programming pic18f4550 in mikroC PRO, using the HID library and I would like to ask for some help here, getting started with the new project I'd like to develop; a USB to UART bridge. The idea is that any received data from the UART gets transmitted from the USB and any received data from the USB gets transmitted from the UART's TX pin.

Except from checking the USB Library, what else should i include in my .c file, and generally, what else sould I do for being able to use the USB Library Routines? Any code would be really helpful to me.

Thank you.

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:10
by T.Jackson
Hello Constructor

Please view the included samples in your MikroC directory, and consult the help file for any other additional information as per required. There are also many great books on the market too.

Incidentally, why do you wish to shuffle data between an obsolete protocol (RS232) and modern day protocol such as USB?

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:19
by constructor
Hi T.Jackson and thank you for your quick reply,

I'd like to develop a small external device for my iPhone where the the data from the iPhone's USB port will be accessible from an other module that I would like to connect, that uses the UART interface.

[iPhone -> USB -> PIC18F4550 -> UART module]

I know that iPhone has a built - in UART port but it won't offer baud rates > 57600bps. Because I would like to run the module's UART @ 921600 bps, I have to go this way.

So... anyway to get started with the mikroC USB Library?

Thank you.

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:24
by T.Jackson
This your first electronics & software related project?

Have fun learning the iPhone protocol.

You're dreaming with your notions.

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:26
by T.Jackson
My reasoning for saying this ...

If you could pull off such a project, then you wouldn't be on here asking for help with USB basics.

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:31
by T.Jackson
The last thing Apple want is some unauthorized person interfacing peripherals to their iPhone products.

Good luck!

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:35
by T.Jackson
Not to say that it isn't possible of course ...

A guy spent 2 years working for MAME hacking into Capcom's CPS2 video game encryption :shock:

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:36
by constructor
I think I'm misunderstood...

This is not my first project in mikroC PRO. Even in elecronics. I've just never used mikroC PRO for developing USB applications. The truth is that i know few about the USB protocol, but i don't think that this project would be hard to be developed.

I'm going to develop the whole thing with a friend of mine who has a great experience in building apps using the External Accessory framework since it was last updated (June 2010).

I'm not that interrested in learning everything around the USB protocol, and I'd just like to create my first hex for the 4550 in order to get the USB's control. That's all.

Thank you again.

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:44
by T.Jackson
You're dreaming.

You would need to know USB inside out and back to front for starters.

You would need low-level programming skills at ASM level ...

It is a tougher enough job figuring out the protocol of a 20 year old Nokia phone (ask Silicon Chip designer Peter Smith) -- let alone a USB-based, and likely encrypted protocol for a modern day piece of high-tech gear such as an Apple iPhone.

If you've got a few years to spare, then go for it buddy. There is no published documentation for the iPhone on how to do this, and if you did pull it off, then it would be as a result of your own hands on, dedicated R&D.

Good luck mate.

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:53
by T.Jackson
As for just USB interface to the PC ...

You won't be able to take it much further than controlling a few LEDs and reading voltages.

What in the bloody hell is the point of this?

You just wanna be the 1 million'th person to do it, is that it?

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 17:58
by constructor
Ok first of all T.Jackson, thanks for wishing me good luck.

Now, after whatching the example's code (HID Read Write Test) I reallized that for some reason all the other interrupts are disabled and I'd like to ask why. Are there any conflicts when using extra interrupt handles, except the HIDs? If so, I'm not supposed to be able to handle UART and USB interrupts in the same program, right?

Something else that I'd like to ask; If I don't use the HID terminal's descriptor, what values will the device get for VID and PID? Is it optional to use it or not?

And again, should I include anything else in my project/c file?

Thank you.

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 18:04
by T.Jackson
There is a working example for USB interfacing in MikroC's directory.

I suggest that you read it thoroughly.

I personally have little interest on the topic, so I am unable to offer you any further assistance off the top of my head. On top of that – I do not feel that you are being genuine. I do not have very much time to spare for non-genuine people.

I know enough to say that you are not about to start an USB project, so why should I waste my time for?

Good luck mate.

Re: USB to UART bridge using PIC18F4550

Posted: 13 Sep 2010 20:15
by drdoug
I do not know much about USB programming but there are lots of resources you can find on this forum. I believe you will find most of the users here to be very supportive here (despite some recent posts which I can assure you is atypical). Search the forum for USB.
USB can be very challenging and if this is your first project then it is ambitious but you should be able to get there with some effort.
I would recommend looking at USB Complete by Jan Axelson for USB basics. Also, if you are going to interface to an iphone, you may need the USB to be a Host controller and not a peripheral.
I hate to point people away from the mE site but Microchip has a much more extensive USB library and resources that you may find helpful. http://www.microchip.com/stellent/idcpl ... m=en534497
Good luck and keep us posted.

Re: USB to UART bridge using PIC18F4550

Posted: 14 Sep 2010 07:01
by T.Jackson
drdoug wrote:I hate to point people away from the mE site but Microchip has a much more extensive USB library and resources that you may find helpful. http://www.microchip.com/stellent/idcpl ... m=en534497
*laughing*

Yeah and that's why it is quad times the price of this compiler ...

I've done my homework mate -- for the money this is the best C compiler available :wink:

Re: USB to UART bridge using PIC18F4550

Posted: 14 Sep 2010 07:21
by T.Jackson
I think that MikroElektronika have been fairly generous with their freely downloadable version which has the only restriction of being limited to 2KB of program space.

Most professional programmers will never even come close to using 2KB, unless they starting using resourceful libs.

There's a lot of good (realistic / down-to-earth) projects that you can do with a dirty cheap 16f628, which has 2KB of prog space.

But most of these guys ...

>> 123456
<< 654321

666

They just wanna store 666KB of text in prog memory and spit it out on an LCD within a project that implements little more than a button and some reference of voltage to measure.