Author Topic: Good PIC tutorial in C  (Read 15188 times)

0 Members and 1 Guest are viewing this topic.

Offline pelle.jansenTopic starter

  • Contributor
  • Posts: 24
  • Country: nl
    • Check out my Youtube channel!
Good PIC tutorial in C
« on: January 18, 2012, 04:43:33 pm »
Hi all,
I am new here and new to microcontrollers. I am a long time subscriber to eevblog on youtube though :D
My 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 arrive  :P
But I have done hours of research and still cant even light a LED  :'(
MPlab 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,
« Last Edit: January 18, 2012, 04:45:41 pm by pelle.jansen »
 

Offline Noize

  • Regular Contributor
  • *
  • Posts: 183
  • Country: gb
Re: Good PIC tutorial in C
« Reply #1 on: January 18, 2012, 05:00:52 pm »
The first lesson "basic I/O" should help you light an led.
Here http://www.gooligum.com.au/tut_midrange_C.html

Just alter the code to suit your microcontroller by referring to the relevant datasheet.
 

Offline caffeinatedbard

  • Regular Contributor
  • *
  • Posts: 66
  • Country: us
Re: Good PIC tutorial in C
« Reply #2 on: January 18, 2012, 05:32:42 pm »
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!
 

Offline metalphreak

  • Frequent Contributor
  • **
  • Posts: 815
  • Country: au
  • http://d.av.id.au
    • D.av.id.AU
Re: Good PIC tutorial in C
« Reply #3 on: January 19, 2012, 11:00:17 pm »
Find the PICC PDF manual in the installation directory. It's 1000+ pages and has a few intro sections that explain quite a bit.

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19895
  • Country: gb
  • 0999
Re: Good PIC tutorial in C
« Reply #4 on: January 20, 2012, 10:18:11 pm »
Learn assembler first LOL. ;D
 

Offline metalphreak

  • Frequent Contributor
  • **
  • Posts: 815
  • Country: au
  • http://d.av.id.au
    • D.av.id.AU
Re: Good PIC tutorial in C
« Reply #5 on: January 21, 2012, 05:19:02 am »
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 :D)

Offline siliconmix

  • Frequent Contributor
  • **
  • Posts: 466
  • Country: wales
Re: Good PIC tutorial in C
« Reply #6 on: January 21, 2012, 08:52:25 pm »
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.
 

Offline pelle.jansenTopic starter

  • Contributor
  • Posts: 24
  • Country: nl
    • Check out my Youtube channel!
Re: Good PIC tutorial in C
« Reply #7 on: February 06, 2012, 09:36:16 pm »
Thanks for the input all! Sorry for the late response. I'm kinda busy with school  :'(
The 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  ;D. 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 Python :P
The 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.

@siliconmix
Try 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!
 

Offline adamhixon

  • Newbie
  • Posts: 6
Re: Good PIC tutorial in C
« Reply #8 on: February 07, 2012, 03:44:42 am »
Here is the first ASM tutorial I ever read: http://www.mstracey.btinternet.co.uk/pictutorial/picmain.htm
Its 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
 

Offline SajjadBro

  • Contributor
  • Posts: 18
Re: Good PIC tutorial in C
« Reply #9 on: February 12, 2012, 08:59:34 pm »
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.
 

Offline juanfermed

  • Regular Contributor
  • *
  • Posts: 86
  • Country: gt
  • Fully characterized performance
Re: Good PIC tutorial in C
« Reply #10 on: March 11, 2012, 02:12:53 am »
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 here http://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/) maybe you will want to go to this webpage http://embedded-lab.com  and 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 to embedded-lab.com.

Hope to hear of your first projects soon, have us updated!!! :D

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 ;D
Batteries are, like any other research area...an area in research.
 

Offline ThunderSqueak

  • Supporter
  • ****
  • Posts: 167
  • Country: us
  • Dont be a freak... dont be a freak... dont be a ..
    • ThunderSqueak!
Re: Good PIC tutorial in C
« Reply #11 on: March 11, 2012, 02:35:03 am »
Always liked BoostC from http://www.sourceboost.com/

Combine this with picpack from http://www.embeddedadventures.com/pages/p/Tutorials/id/29

toss in the stand alone programmer http://www.microchip.com/forums/m554515.aspx

Embedded adventures has some good tutorials too.   

check out both (old website) http://embeddedadventures.blogspot.com/
and (new website) http://www.embeddedadventures.com/



« Last Edit: March 11, 2012, 02:49:49 am by ThunderSqueak »
Currently working with non-binary computing, no reason for it... just doing because I can ^^
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf