Difficult to write a complete code for microcontroller

Thread Starter

anhnha

Joined Apr 19, 2012
905
I have some basic understanding of microcontroller, C programming language and did some projects about this. However, I just got a job relating to this and realized that I lack lots of knowledge to write a complete program on my own without copy, paste and edit some sample code from the net.
My work place doesn't allow to use the Internet so I get depressed and couldn't write a complete code and make it work without searching the net.
Now I have to study actually how to use microcontroller in detail such as memory map, makefile, set fuse bits, WDT,...
I use PIC 16 and 18 families and run it on PIC C compiler and MPLAB.
Could you give some advice and some links/guideline so that I can write the code on my own?
I am allowed to use datasheet there is lots of concepts that I can't understand.
PS. I found this page extremely good.
http://www.mikroe.com/chapters/view/16/chapter-3-pic16f887-microcontroller/
 

adam555

Joined Aug 17, 2013
858
I began with PIC microcontrollers from scratch just a few weeks ago, and couldn't find a good tutorial for C and the PIC16F family. So, I found it really hard at first, but by looking through a lot of different sources -including many questions on this forum- I learnt the basics of how to use each peripheral, and now all I need is the datasheet -mainly as a reference for pins and registers-.

So that's my advice: learn to use each peripheral in C; it's not that many, so it won't take you long.
 
Last edited:

Thread Starter

anhnha

Joined Apr 19, 2012
905
Thanks for the advice and tutorial! I will spend some time reading them carefully.
Also, I find it hard to understand fuse bits, WDT, choosing oscillators. Do you write these yourself?
 

adam555

Joined Aug 17, 2013
858
And this is a full tutorial, also for PIC16F with MPLAB XC. It's an in depth course of 42 videos based on the book: "Designing Embedded Systems with PIC microcontrollers":

 
Last edited:

adam555

Joined Aug 17, 2013
858
Thanks for the advice and tutorial! I will spend some time reading them carefully.
Also, I find it hard to understand fuse bits, WDT, choosing oscillators.
You have a tool on MPLAB X that generates the fuse bits for you specific to whatever PIC you are using. In the menu go to "Windows > PIC Memory Views > Configuration Bits"; set them up as you wish, click generate, copy the result in your code, and you're done.

I didn't need to use the WDT function yet, so for now I can't help you, but I can guide you with the oscillators.
 

Thread Starter

anhnha

Joined Apr 19, 2012
905
Thanks a lot! I will try to digest these tutorials first before moving on. :) It will take some time.
I spend one all day yesterday reading about oscillator (how it work, how to choose capacitors, resistors) but it is still obscure. I find the language in datasheet hard to understand. I usually consult lots of dictionaries but sometimes I get lost. :confused:
 

adam555

Joined Aug 17, 2013
858
I understand what you mean: the datasheets are better as a reference guide than a place to learn.

About oscillators, you can use the internal oscillator (which is the simplest option), a crystal, or an RC oscillator (which I guess is the hardest). You choose these options through the configuration register (the fuse bits); as well as whether you want the WDT on or off.
 
Top