PIC18F & Microchip C18

yngndrw

New Member
Hi,

Well I started out wanting to learn some ASM, learnt a bit and found that programs in ASM take too long to develop.

Seeming that I already know a lot of C (For Windows, mind) I thought I'd start making my programs in that instead.

I've managed to make a multi-tasking system which runs multi-channel PWM quite nicely. I've got this hooked up to the three colours of an RGB LED so I can make pretty colours in my room. I've also got an LCD working off a shift register, but that's beside the point.

I'd now like to add sequences to the light.

I found this awesome site in someone's sig here: **broken link removed**

That project is a pretty nice RGB LED controller and I'd like to design my own version of it using USB.

In his ASM he used "dt" to store the light sequences in a data table. What is the best method of doing this in Microchip's C18 ?

Also I've found a few little things on Google but nothing too helpful: Are there any guides about using USB with the PIC18F2550 / 4550, in C18 ? A USB bootloader for them PICs with C18 source would be nice if anybody can link me.

Edit: I found some nice looking USB examples:
http://www.sixca.com/eng/articles/usb_cdc/index.html
http://www.sixca.com/eng/articles/usbdaq/index.html
http://www.sixca.com/eng/articles/usbstepping/index.html

Still looking for tutorials though.

Thanks,
-Andrew.
 
Last edited:
You can store data in the flash ROM like this:
static ROM unsigned char YourStuff[] = { 0x3c, 0x68 };
 
You can also include the original assembly data file, make the data pointer global so it is visible from C, and then C can just access the data through the pointer.
 
There is the **broken link removed**. It uses the same (microchip) firmware as the other page you found. The slight advantage with the UBW is that it is available from Sparkfun as a prebuilt module. Sparkfun also has a forum dedicated to it.

Mike.
 
Thanks for your replies.

For the static ROM method, what would be the best method of finding out the size of the array ? Is the size_of() function implemented in the C18 compiler ?

I think I'll stick to just the one language to neaten and simplify things a little. Thanks for the idea though.

Edit: Replied at the same time. Thanks for the link, I'll look into that more.

Edit2: Just noticed that the UBW uses COM Port emulation. This is no good to me as the reason I wanted to support USB is that I'm running out of decent COM Port numbers (COM1, COM2 etc). Am I reading it right that it emulates the COM Port ?
 
Last edited:
The UBW has a bootloader that can load any code. The examples on that site are serial but could be any USB device. Have a look through the application notes on Microchips website for some examples.

Mike.
 
Is the size_of() function implemented in the C18 compiler ?
Yes, the sizeof() operator will work in C18
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…