View Full Version : [Question(s)] PIC Microcontrollers

03-23-2009, 11:09 PM
Hey I was wondering if anyone knew about the Microchip PIC 18F4685 and other PIC microcontollers. I have used the Basic stamp, SX, and PICAXE microcontrollers in different variants of BASIC and assembly but I am now learning to program in C++ and I want to use the PIC 40-pin microcontrollers for my custom circuitboards but the pinout confuses me. I cant even tell which pins are inputs, outputs, or I/O. Can anyone explain this to me or find a better datasheet? Please tell me if you need me to show you the ones im looking at... :happy:

03-23-2009, 11:12 PM
By the way im onlya 15 year-old teenager with limited experience so im not as amazing with programming and microcontrollers as most people here... :veryhappy:

03-23-2009, 11:37 PM
Take a look at the Arduino. While it's an AVR and not a PIC it is a good learning platform and has good community support.

03-24-2009, 01:38 AM
You're probably confused since almost all pins on a pic are both input and output, depending on how you set them.
I agree with jes1510, they're not the easiest thing to start from, but if you're willing and determined, they give you a really sturdy background in microcontrollers, both in programming and understanding the way the way they work internally, which is highly underrated most of the time.

Be aware though, though pics are widely used and cheap, they have their quirks, you might save yourself some frustration by learning eg. AVR microcontrollers, or something 8052-based (like silicon lab's or analog devices aduc8xx series)

03-24-2009, 09:47 AM
Also, which compiler are you planning to use? Don't most of the PIC compilers cost quite a bit?

As for C++, the truth is that most compilers for 8-bit microcontrollers are C compilers, with some limited C++ extensions. For example, the AVR-GCC compiler fully supports C99, and you can also use C++ classes, but it lacks the new and delete keywords -- thus classes are not automatically dynamic (you have to create your own malloc based functions). Personally, I think that the use of C++ on a micro is overkill, and typically is a hack due to compiler limitations -- its better to just learn to use C correctly. I think you'll find the same is true for PICs. /rant


03-24-2009, 02:52 PM
There are quite a few compilers out there that aren't too expensive, or even free although with limitations.

I'm pretty fond of MikroC from Mikroelektronica, they have C, basic and pascal compilers for pic, avr, and i think even ARM etc. Compilers are free up to 2k code, so as long as you're not using floating point math you can go a long way.

But indeed, I'd stick to C as well. Personally I don't see the advantage in using classes with microcontrollers, but then i don't see the need in using classes when working on a pc either.. i'm just a low-end programmer guy..

03-24-2009, 04:51 PM
I am currently trying out the Code::Blocks compiler. Its a free compiler from www.Cprogramming.com (http://www.Cprogramming.com) and has an option for using C or C++ (and has the new and delete keywords) and was partly designed for AVR projects, so like you guys said, I think I'll use AVR Microcontrollers instead. Sounds like a good start ! I'll check out the Arduino and any other links or forums anyone knows are appreciated! :happy:

03-24-2009, 05:38 PM
After some research I found the Freeduino SB which seems to be a slightly better alternative to the Arduino (everything is the same except for it has mini-b USB jack, a power switch, and an optional ARef trimpot for analog input scaling) and i will probably switch out the Atmel ATmega168 with a Atmel ATmega 328P-20PU version which has about twice the flash, EEPROM, and SRAM memory of the Atmel ATmega168. :happy: If anyone has any other info or suggestions I'm happy to hear them!

03-24-2009, 07:27 PM
if you ever feel like picking the pic back up. just send me any questions you have. I used to work for Microchip. While I was there I wrote software for them.

and to answer your question you have to set the pins on the PIC to be output or input

it'll be something like TRISA01 = 1 for input, 0 for output, the A01 changes depending on which pin u want to use.

03-24-2009, 08:46 PM
Ok sweet ill ask you if i do. I probably will experiment with PIC and Atmels and see which one i like better. I like the PICAXE series but i can only use visual basic on it... Ill do some research on PIC microcontrollers. :happy:

03-24-2009, 11:19 PM
you can get microchip compilers for free. It only does ANSI C.

you have to get the student version for it to be free, but the only thing your not getting is code optimization. But if you really need a size efficient hex file just email your code and i can compile it for you and save you those extra bytes.