Good PIC tutorial in C - Page 1
Forum section: electronics / general

author: pelle.jansen
author_rank: Contributor
timestamp: January 18, 2012, 04:43:33 pm
content: Hi all,I am new here and new to microcontrollers. I am a long time subscriber to eevblog on youtube thoughMy electronics skills were going up and up so I decided to give MCU's a try.I have ordered a PicKit 3 + a few PIC16F's on ebay and cant wait for them to arriveBut I have done hours of research and still cant even light a LEDMPlab X , HiTech PICC lite, C18 and MPASM(not that i'm gonna do any assembly any time soon) are installed.Right now I have no Idea how to set a pin as output and then set it high. I did get delay working tough.So, does anyone know a good turorial or lesson to tech me this?I'm fluent in Python, know some C and have never seen a word assembly in my life.Thanks,

author: Noize
author_rank: Regular Contributor
timestamp: January 18, 2012, 05:00:52 pm
content: The first lesson "basic I/O" should help you light an led.Herehttp://www.gooligum.com.au/tut_midrange_C.htmlJust alter the code to suit your microcontroller by referring to the relevant datasheet.

author: caffeinatedbard
author_rank: Regular Contributor
timestamp: January 18, 2012, 05:32:42 pm
content: http://www.mikroe.com/eng/products/view/11/book-pic-microcontrollers/Very good tutorial even though it is based on their compiler. You should be able to extract information that can be applied across all families though.Good luck!

author: metalphreak
author_rank: Frequent Contributor
timestamp: January 19, 2012, 11:00:17 pm
content: Find the PICC PDF manual in the installation directory. It's 1000+ pages and has a few intro sections that explain quite a bit.

author: Zero999
author_rank: Super Contributor
timestamp: January 20, 2012, 10:18:11 pm
content: Learn assembler first LOL.

author: metalphreak
author_rank: Frequent Contributor
timestamp: January 21, 2012, 05:19:02 am
content: Assembly is a good thing to know, if only for background on how the micro works. For most introductory hobby uses that don't require exact timing or absolute low level control of hardware, C programming is more than adequate (especially when libraries take care of all the boring stuff)

author: siliconmix
author_rank: Frequent Contributor
timestamp: January 21, 2012, 08:52:25 pm
content: welcome pelle.i'm at the same place as you.having said countless times i wouldn't go down the microproccesor route .necessity has forced me to begin learning.i've not started yet just been looking at all the programmers and ic's.i did a little basic years ago nothing fancy but i'm totally stumped as which type to go for.

author: pelle.jansen
author_rank: Contributor
timestamp: February 06, 2012, 09:36:16 pm
content: Thanks for the input all! Sorry for the late response. I'm kinda busy with schoolThe gooligum tut was very helpful and got me started with digital IO! With some help of this great forum my leds are now blinking to my buttons. Also thanks to the gooligum tut I now have some idea into assembly. Enough to be able to read simple programs (i am a quick learner). Writing them is still far out of reach and will stick to C for the time being. Unless something magical happens and it will be possible to use PythonThe build in manual is helpful but a bit too complicated for my level. I will remember to use it when my level goes up.By the way: whats up with the button on the debug express demo board? I don't seem to be able to get it to work while my PIC16F877A on my breadboard works like a charm. It is on RB0 right? And it has hardware pull ups according to the pickit 3 demo board schematics.@siliconmixTry the gooligum tutorial. With some common sense it will get you started as it did with me. But don't expect it to work out of the box!

author: adamhixon
author_rank: Newbie
timestamp: February 07, 2012, 03:44:42 am
content: Here is the first ASM tutorial I ever read:http://www.mstracey.btinternet.co.uk/pictutorial/picmain.htmIts quite dated now but short and simple, Might be a good idea to run through it first just to get an idea of whats really going on before you start in on C

author: SajjadBro
author_rank: Contributor
timestamp: February 12, 2012, 08:59:34 pm
content: Learning Assembly is must so you know what actually is happening. You get very close to know hardware Architecture and how it works and what is its limitation. I haven done 8051 in assembly so when i moved to PIC (about 4 months ago) i didn't need to learn Assembly. I am using MikroC pro for PIC and i realized that this compiler handles most of the things itself but in Assembly you have to control almost all bits and timings almost everything yourself.

author: juanfermed
author_rank: Regular Contributor
timestamp: March 11, 2012, 02:12:53 am
content: Hi! As many people says, learning assembly is good for you to understand what is happening in the background. As C is a high level language (not too high level like python, but no so low level as assembly) it lets have good control of the microcontroller. Anyway, as you are starting, I would suggest you to stick to C as much as possible, and when you feel you are a pro, maybe move to C++ (I am a newbie to C so I havent made that move). Also I have used MikroC compiler from mikroe.com.You cand download an evaluation version of mikroC which its only limits is 2kb of code (you cannot write very long programs) but for me it has been more than enough. If you decide to use this software (which you can download from herehttp://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/) maybe you will want to go to this webpagehttp://embedded-lab.comand look for the "PIC Tutorial" section. They go from the very basics (Input/Output, how to make some registers work, ADC, UART...) and make very interesting projects with not too hard language. The best thing is that they are very well explained and I am learning from there too right now, you not only learn about the PIC, but about many many other components like sensors, amplifiers, transistors, connections and many other cool stuff. The thing is that they use MikroC for the tutorials so you are done!I really suggest you to use mikroC, it is very easy, continue learning C (when you switch from PIC to many many other microcontrollers you will notice the use C also) and go toembedded-lab.com.Hope to hear of your first projects soon, have us updated!!!PIC microcontrollers are widely known in the web, and I know something, even being that way, it is hard to get started. It is good you found a forum like this were a lot of people are willing to help.P.S.: I really dont think you are gonna get to write code for PICs in Python in the near future, as far as I know, there is no compiler that can translate python to PIC assembler, and then to its hex. Python is really easy, but maybe you will find yourself writing code in Python for your computer, to comunicate externally with a PIC, via USB for example

author: ThunderSqueak
author_rank: Unknown
timestamp: March 11, 2012, 02:35:03 am
content: Always liked BoostC fromhttp://www.sourceboost.com/Combine this with picpack fromhttp://www.embeddedadventures.com/pages/p/Tutorials/id/29toss in the stand alone programmerhttp://www.microchip.com/forums/m554515.aspxEmbedded adventures has some good tutorials too.check out both (old website)http://embeddedadventures.blogspot.com/and (new website)http://www.embeddedadventures.com/