How to Program PIC18 Microcontroller in C. Step by Step Tutorial (Pictorial Views)
Microchip Technology is the 2nd largest electronics and IC fabrication industry. Microchip Technology sells microcontrollers in 6-pin packages (PIC10F2xx series) , 100-pin packages (dsPIC33EP512MU810) and even 144-pin packages (some PIC32 devices). Also, there are many previous series like PIC12, PIC16, PIC18.
Now the below window will appear. This is your programming Environment on this window you have to write code and compile it.
Each port has TRISX Register which defines that you are using this port for the input or for output. Where X can be, A, B, C, D, E, F e.g. TRISB.
For output you have to put 0x00 in TRISB and for input you have to put 0xFF in it. but this is not always the case because Each pin can be independently selected as an input or output. you could write 0x09 to TRISB which would select RB0 and RB3 for inputs and the rest of the pins for outputs.
In mikroC I have selected the delay library so I don’t have to create the delay functions here I can simply use Delay_ms() function. In this function you have to give how many mili seconds delay you want like if you want 1000 mili second delay you can write it like Delay_ms(1000).
TRISB=0x00; // Defineind as Output
While(1) //Infinite loop
Delay_ms(500) ; //500 miliseconds delay
Once the hex is created you can burn this hex in your PIC18f452 by using PICKIT hardware or you can test it by using proteus.
That’s all about this first tutorial; stay tuned for upcoming posts about the topic.
You might also read:
- MAX232: Construction, Operation, Types and Application
- Clap Switch Circuit Electronic Project Using 555 Timer
- 10+ Design & Simulation Tools for Electrical/Electronics Engineers Online
- SMD Resistor Codes: How to Find the value of SMD Resistors