How To Ideas | How To Articles | How To Tutorials


0

Tutorial 0.0–PIC(18F) Microcontroller Programming in C (I/O Interfacing)


This is PIC Microcontroller 1st tutorial and in this tutorial we are going to learn, how to interface I/O Ports with PIC Microcontroller. PIC(18F4550)  Microcontroller has 5 I/O Ports(A,B,C,D,E) those can work both as Input and  Output. To program PIC Microcontroller in C you need MPLAB IDE which can easily be downloaded from Microchip’s site.

  1. To make any Port I/O you need to remember one keyword which is TRISX (X is Port Name you are using). Now if you write TRISB=1 this will make Port B as Input and writing TRISB=0 make Port B as Output.
  2. Lets see a program in which Microcontroller gets Input from Port B and display Output at Port A. The program begin by writing #include<p18f4550.h> where p18f4550.h is the header file you need to attach with your Project. Click here to see how to attach files in MPLAB IDE.

    #include<p18f4550.h>  Header File attached to Project
    void main()
    {
    TRISB=1;              Make Port B as Input
    TRISA=0;              Make Port A as Output
    while(1)              Super loop
    {
    PORTA=PORTB;          Copy Data at Port B to Port A
    }
    }
     

  3. while(1) {  …….} is called the Super loop and is used when you are using file for hardware.
  4. This program will continuously copy data from Port B to Port A. If you need to See the Program working in your computer you can download PIC Simulator IDE and watch your program working.
  5. Keep trying these type of Programs. Enjoy…

Incoming search terms:

  • pic 18f* programming c tutorial (2)
  • microcontroller 5 i/o (1)
  • pic16 port io c code (1)
  • program timer in pic 18f4550 (1)
  • superloop programming (1)
Filed in: Electronics, PIC Microcontroller Tags: , , , , , , , , , , , , , , , ,

Leave a Reply

Submit Comment



© 7162 How To Ideas. All rights reserved.
Proudly designed by Theme Junkie.