Back to Browse

PIC18F452/PIC18F4620 blinking LED using Timer0. Tutorial with Proteus demonstration.

851 views
Sep 14, 2023
16:10

Guys, My lectures are free for everyone. If you want to support my channel, then become a Youtube member by following link below: https://www.youtube.com/channel/UCpdIWTTY36Dhyb20V4EnMiA/join Seek knowledge from the cradle to the grave /// /////////////////////////////////////////////////////**********************************///////////////////////////////// Hello guys, Welcome to Learning Microcontrollers youtube Channel, Guys I have also compiled course on Udemy as well. Where you will learn under my direct supervision in a more supervised way. Here is the links to the courses I have on Udemy, By taking any of these courses you will be supporting my channel aswell. This will help me to make more videos with better hardware in the future. I hope you look forward to it. Courses Links: 1- https://www.udemy.com/course/pic16f877a-interface-lm35-temp-sensor-mikroc-collection 2- https://www.udemy.com/course/mikroc-for-pic-libraries-with-examples-using-pic16f877a-mcu 3- https://www.udemy.com/course/mikroc-for-pic-libraries-with-examples-using-pic16f877a-mcu 4- https://www.udemy.com/course/pic-microcontroller-using-mikroc-for-pic-from-scratch 5- https://www.udemy.com/course/learn-arduino-uno-coding-using-arduino-ide ///////////////////////////////////////////////////// Hello guys, We are very much familiar with a delay command.. But incase of many industrial application that command fails to generate exact delays. Because Delay command is only the repetition of the NOP commands. So to avoid this the proper way to generate a delay is to use timer as counter. PIC18F452 and PIC18F4620 has 4 timers and timer 0 in both is 16 bit. So we use this. Code in video is as: MikroC version 5.6.1 void main() { PORTB.F0 = 0; TRISB.F0 = 0; PORTB.F0 = 0; T0CON = 0x07; /// 1:256 while(1) { PORTB.F0 = 1; /////////// Delay of 500ms using timer starts T0CON.TMR0ON = 1; /// Timer 0 enabled TMR0H = 0xD9; /// FFFF FF = H FF = L TMR0L = 0xDA; while( INTCON.TMR0IF == 0 ); T0CON.TMR0ON = 0; INTCON.TMR0IF= 0; /// cleared the register /////////// Delay of 500ms using timer ends PORTB.F0 = 0; /////////// Delay of 500ms using timer starts T0CON.TMR0ON = 1; /// Timer 0 enabled TMR0H = 0xD9; /// FFFF FF = H FF = L TMR0L = 0xDA; while( INTCON.TMR0IF == 0 ); T0CON.TMR0ON = 0; INTCON.TMR0IF= 0; /// cleared the register /////////// Delay of 500ms using timer ends } }

Download

0 formats

No download links available.

PIC18F452/PIC18F4620 blinking LED using Timer0. Tutorial with Proteus demonstration. | NatokHD