Learning PIC C

With the exciting release of all the information for our new RC, as the head programmer for my team, I will soon be teaching all the new (and old, though I don’t think they will really need teaching) team programmers in the art of PIC C (which I can mostly do), the use of Microchip IDE (which I am learning), and maybe even the delicate art of ASM (which I am decent at). The only problem is, I’m not the best teacher in the world. I can do stuff, but I can’t really explain it all-to-well. So, my request is this: does anyone know of where I can find any good (read free) tutorials for any or all of the above?

Does anyone know where I could get a free editor for that matter for PIC C. And does anyone know how indepth C it supports. Like do you use malloc/calloc with pointers etc…

The three first PDFs listed on Microchip’s C18 product page are pretty good, comprehensive documents about the C18 compiler, which is a non-free addon to MPLAB. Being as MPLAB is listed as the programming environment which we’re going to use, I suspect that we’ll be using it in conjunction with C18, to program the controller. The User’s Guide contains a lot of the language specifics, while Getting Started provides a nice little introduction, including a couple code examples (though there are enough of those in the User’s Guide, as well). The third document is an overview of general libraries from Microchip, in order to take advantage of certain capabilities of the processors.

I’m going to be in the teaching position, again, for this year, too. I’m going to stick with the same strategy I had last year, though. Throw the manual at them, and answer any questions they ask me. If they do anything that looks like it’ll damage anything, I’ll try to let them know before they run it. :stuck_out_tongue:

There are a lot of books on the pic microcontroller. I have bought too of them but I really have not had the time to learn them with school. One book is on learning how to program using pic-lite and the other book is actually a rather large book about almost every pic in existance.

*Originally posted by Adam Y. *
**There are a lot of books on the pic microcontroller… the other book is actually a rather large book about almost every pic in existance. **

I have one of those in my room. I find it’s easier to look up data sheets on Microchip’s website, though.

On my team’s website http://www.steeldragonrobots.com
there is a programming forum where we will post links to online tutorials and resources, as well as quickly answer any individual questions. Check it out.

Hmmm, seems kinda laggy, whatcha hosting it on?

Well, I suppose here’s the question that is nagging everyone’s mind: (well, some one’s mind, probably)

Is there a Linux IDE for the PIC microchip? I haven’t looked very in depth for one yet, but I plan to begin to soon. If anyone knows of one off the top of their heads, it would be helpful.

I wish FIRST would step back from proprietary software…

Is there a Linux IDE for the PIC microchip? I haven’t looked very in depth for one yet, but I plan to begin to soon. If anyone knows of one off the top of their heads, it would be helpful.

There is but they don’t support that certain chip.

Does anyone know where I could get a free editor for that matter for PIC C. And does anyone know how indepth C it supports. Like do you use malloc/calloc with pointers etc…

My suggestion: Keep it simple!

You have less than 2K of RAM to work with. Dynamic memory allocation is very tricky and it is very easy to get lost.

There is no doubt that we will need to use pointers, but I plan to keep it to a minimum.

Also, beware of recursive calls.

Bottom line: You don’t want to have your team on the sideline during a competition just because your programmer got “cute”.

'nuff said.

I can hardly imagine a situation in which you will need to implement malloc/calloc . In fact, I’m starting to have difficulty imagining too many situations in which assembly would be needed (though convienently possible on the PIC…)

I’ve been programming PIC 18F452 for almost a year and have a pretty good understanding of the chip now. The 18F8520 is so new, I haven’t found any development/evaluation boards for it yet.

The MPLABS IDE is a simple IDE, but eventually I switched to Komodo as it works with CVS (concurrent versioning system). For programming, I’ve been using the Melabs EPIC programmer.

Hi-Tech sells a C compiler for the PIC which will come with a Windows version and a Linux version, but is expensive. C2C is cheaper. The CCS compiler is a popular choice, but isn’t fully 100% ANSI C.

No SDCC or GCC port yet, but I’m still hoping this will change soon as the incentive is there. The 18F now has enough of a stack to make this possible now.

Each compiler accesses the PIC hardware with different semantics, so changing compilers means you have to rewrite the code.

As for an IDE, you have many choices besides VI (vim) and Emacs/Xemacs such as Eclipse, Kate, KDevelop, Komodo (ActiveState.com) and Kylix. I probably missed a few, but these are the ones I’m familiar with. Most of these can be extended to support the compiler and a download utility.

For programming a PIC, there’s PonyProg and PP06, neither of which I’ve tried yet as I haven’t yet completed my Windows to Linux conversion on my last Windows box.

Btw, check this out: http://www.penguicon.org

Linux rocks! Windows sucks. Why pay the Microsoft tax on your computer?

Do you know the websites for Hi-Tech, C2C, and CCS?
I am a bit confused by what you mean, so let me say it as I understand it:

Use any IDE to code…
Use Hi-Tech, C2C or non-ANSI CCS to compile
Use EPIC to program

Is that the process that one goes through?

BTW: I have been seriously considering making the programmers on my team use CVS or RCS… any suggestions on how to make them comply?

The BAS system. (Big $@#$@#$@# Stick… as in 2 by 4, not male organ) Hit them over the head with it if they don’t check in and out with CVS.

My guess is that you won’t program the PIC with a multi-socketed external programmer, but with a system like last year’s; you’ll leave the SMD soldered onto the board inside the RC (so as not to void the waranty), and attach a COM port or Mac serial port to the supplied programming port on the outside of the RC.

The MPLAB IDE will probably have a driver for this method, so you just have to enable it via a pull-down menu, and blooey, it’s blown into the RC’s memory. The IDE works competently (at least versions previous to 6 did - I’ve put the required new firmware into the PICStart, using a ver 5.x, and downloaded the latest version of 6, but I haven’t tried v6 for real).

If the default program is anything like it has been for a number of years, now, there will be libraries and alias-renaming blocks, and “DO NOT CHANGE THIS” areas. There will be many examples, in the program and online. In short, not an insurmountable task.

Have fun :slight_smile:

Over the summer, I worked with a Cerebellum, a development board for the PIC16F877 developed at CMU, and it uses the same serial port for both programming and serial communications. You just leave the PIC in it’s socket, and the board has I/O pins on it. I imagine a similar setup will be used by Innovation First (considering that having everyone removing the chip, programming it, and putting it back in will probably result in several snapped pins, if not chips, during the heat of the competition)

So I went and actually looked at the sheet for the 18F8520, and it has a bus available to address an acre or two of external memory (will the IFI RC ?), 32 k of internal program memory and 2 k of variable space in RAM and 1k in EEPROM. It has hardware serial communications options including a USART (rs232,488 &c), and IsquaredC, as well as all the stuff to read the PWM inputs.

The programming for all these goodies will probably be in the library supplied with C-BOT.

*Originally posted by Lloyd Burns *
**The programming for all these goodies will probably be in the library supplied with C-BOT. **
The default code for the EduRC was released yesterday (10-16-03). It’s available here, under Documentation.

Thanks to all that answered my question of where to get good teaching aids (or however exactly I phrased it). A particular thanks to those who posted links to useful sites. Overall, a good thread, and helpful to me, so thank you on the whole.

Jesse - as for our team going CVS … maybe, we shall see … personally I am liking MPLAB a lot, which apparently doesn’t support it, so … we will talk