By Abdul Rehman
PIC Microcontroller 16f887 assembly code example for LED blinking is very simple and easy to implement. This is why it is always recommended to blink an LED for any embedded system development beginner. The microcontroller PIC16F887 is used for demo purposes but this code is equally applicable to other variants of PIC16 micro-controllers, like PIC16F877A or PIC16F84A etc.
We are using Proteus simulator for simulating our code but if you are testing the code in real world test bench all you need is,
After wiring LED and crystal to the microcontroller and giving the proper supply connections, you are good to start.
Here we are breaking down the code into three main parts. The first one is the setup and after that a infinite loop which will toggle the LED continuously and in-between the toggling, we required to call some routine which will waste some of the CPU cycles of the microcontroller. This routine is delay routine. So, once we are done writing the delay routine we can use that in our main loop and call that routine which will delay the process of blinking so that human eye could witness the blinking. The amount of the delay is actually inversely propostional to the speed of the blinking.
Here is the complete code for the LED blinking in PIC16F887 microcontroller using assembly language.
Code language: PHP (php)
LIST p=16F887 ;tell assembler what chip we are using #include <P16F887.INC> __CONFIG _CONFIG1, _INTOSCIO & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF & _LVP_OFF & _DEBUG_ON CBLOCK h'20' COUNT1 COUNT2 ENDC ORG 0x00 MAIN: BANKSEL TRISB BCF TRISB,0 BANKSEL PORTB MainLoop: BCF PORTB,0 CALL DELAY3 BSF PORTB,0 CALL DELAY3 GOTO MainLoop ; Do it again... DELAY3: DECFSZ COUNT1,1 GOTO DELAY3 DECFSZ COUNT2,1 GOTO DELAY3 RETURN END
Here is the final output simulated in the Labcenter Proteous ISIS
11 May 2021
27 April 2021
10 February 2021
03 February 2021
27 January 2021
FYP Solutions Powered By Impressive Business WordPress Theme