This Is The Tomorrow That I Can SEE.."HOPE"
OK i think from the title you know this is a engineering stuff...If you interested in this please continue to read on ...if not wait for my next post that will come up once i go work..
It come across my mind that , many people seeking for information that is lack in our college..there's very little information in our library and we don't have much people to help us out in PIC programming either.
I decide to post up a series of link that let other people benefit from what i have learn previously during my Project Lab with my dear best Joshua..This dedicated to you also Mr Yam.
Bear in mind this is just a beginner simple guide .. it wont led you too far away.There maybe certain information that you have come across!
First Phase:
In this phase i assume you are totally new to Microcontroller..
Here's a little advice , that's always good to have your data sheet download and look through it, dont just glance on the pin but also all the feature that microcontroller have.If you have time , just go through the whole data sheet..But i think is rather hard for some people as like 16F877 microcontroller have more than 100 pages.
Learn more about ur microcontroller first before you proceed .. What you need to focus is:
- Feature that in this microcontroller
- Is the feature suite to what you need?
- Is that microcontroller enough for you to interface with the peripheral?
- Lastly , Is your program too large for the microcontroller to support??
Next look into File Register Map, this is very important as you will very frequent refer to this map .. when you writing a program it often consist of few elements:-
- Initialize state (Eg:Declar Particular Port as input or Output, name your register
- Main Body (Whole program instruction code is in here)
- Subroutines (a series of program instruction that will be use in your main body once it called out by main body program instruction using instruction :eg Call or Goto
- Macro (This act as a external library , macro act like include file . This feature is very useful when you wan to shorten your code , but skip this before you learn all the basic as thing will get complicated and mess up when you dont know what you are programing)
This section is where all the features come in Eg:Timer ,Indirect Addressing.
take a look what you need in your project and mark down the Register.
Tips:Print out a hardcopy of special function register to refer to when you are programming in that way is easier for you to program and think of how to use those Register and implement them in your program.
If you continue to read your data sheet ,you will find down there have a lot of explaination for each Register , how you can activate them and make them your worker to work out with you.
It's above is too little for you all or too bored .
What X14 mean is 14 bits microcontroller.Dont worry about those bit if you are using x12 or midrange x16..The basic still the same for all the microcontroller.
More in detail about mid-range microcontroller:
This tell you more about the feature in detail than what you have learn in the particular Microcontroller.
Second Phase:
Once you have determine your microcontroller and understand the architecture.Proceed to programming stage.This is the phase that you spend most time on.
Start off with very simple programming like on LED , dont just copy the coding and paste it wont help you learn how to get your code on hands. Understand the coding by refering to the certain microcontroller Data Sheet what all the command and register about..All the command or instruction code can find through google if you using mid-range device , you can search through the PDF link [Mid-Range Manual] on section 29.
Where you get simple coding with comments beside to guide you?
If you are new to PIC most probably when you search in google or forum many people will tell you about nigel tutorial .. His hard work mean a lot to many people..Take a look on those tutorial.Start with simple program first!
All this is in assembly form , what if you wan a simple programming.
What i learn from those expert is:
- Assembly give u accurate timing.
- C language give u easiser work when you deal with math equation or algorithm.
Here i make a conclusion for you :-
Microelectronika given out a lot of freebies you can search and one of the freebies i love the most is their E-Book .There's some book for assembly and for C..Click on the link and read through it.They have good diagram to explain everything in detail for you what's more they even teach you C/Assembly language along the way.
Try your luck HERE , click on any selection and click on the Search , you will get a list of application notes . It helps!!
Tips: I got no doubt that for a new user you might stuck there whole day reading more than 5 times the same sentence , there's always something easier out there , don't just focus on one thing if you cant understand it move to another file if you think u still not that level to understand the application notes.
How to program Assembly language using MPLAB IDE??
1.Download MPLAB IDE from Microchip
2.Open MPLAB IDE
3.Go to Project>Project Wizard
4.Click Next into this windows:
5.Next to this for assembly language:
6.Give your project a name:
7.We are done for setting up a worksheet:-
8.Click on new file to get a new file:
9.Click on that untitled windows and go to file>save as:
10.Give your file a name ,remember that file must have extension of .asm or else your coding wont be able to recognize as assembly language.
11.Go to source file >right click on source file and select add files>browse for the place that you have save your .asm file previously.
12.Select the file that you had saved as .Asm and open.
13.At last your worksheet should be something like this :-
If you enter any valid instruction set for example movlw it will appear blue in color and comment will be green.
How you going to program C language using MPLAB IDE?
If you are using C language click HERE to see how to program using C language.
Third Phase:
Programming is always a headache when bump into troubleshooting code and here's what you learn the most from when you make mistake and try to troubleshoot.Enjoy this section since you cant avoid it , but you can ask for some little help from expert in forum:
They will mostly help you out what you want to know , bear in mind that dont throw the whole page of long coding to people and ask for troubleshoot . If you wan a fast solution extract the code that you dont have any resource to depend on anymore and ask people for help.They will most likely help you out with sincere heart.
Personally i like Electro-Tech as their member is very active , although some resource i cant get through them but they help me a lot more than i can ever imagine.
Here's a small little guide from my experience , if your microcontroller come out with some really weird result dont just search in your code but also your hardware.
- DO NOT LEFT /MCLR unconnected ,as floating will cause it to reset when noise is receive on the pin.
- Always use capacitor at where the pin your crystal is operating , as crystal is small actually small vibration when activate by microcontroller.Thefore a little noise will led to unusual output.
- Crystal should be attach on the power pin too (Vcc and Ground) to reduce noise too.
- Do not hold the microcontroller pin with your finger as electro static will kill it.
- Try not to keep deattach your microcontroller from testing board.
Don't Feel Upset When You Fail!
Happy Learning!
"Notice:Any broken link please inform me."
1 comments for this post
I want to use two AD port for different potentiometers. Do you know how to program this in C? One is for frequency adjustment and another one for volume. So they have different scales. I want to put them on LCD display.