Here is the simple blink LED program in embedded C language run in Keil µvision.
Let, 8 LEDs are connected to the PORT P2 of the AT89S52. You can use any port or a single pin eg. #define LED P2^1. This will select single pin of the microcontroller port.
- Now, go to debug option in the bar below the menu bar. See the below image to find debug option
- Now, go to the peripherals option in the menu bar and select the appropriate port according to the program.
- Last step, run the program by clicking on the run option (specified in the below image). You will find the blinks of the marks on the selected peripheral port. This shows that your program is running properly and accurately.
Let, 8 LEDs are connected to the PORT P2 of the AT89S52. You can use any port or a single pin eg. #define LED P2^1. This will select single pin of the microcontroller port.
Code to blink LEDs
#include "REG52.h" // it is the header file of AT89S52 µcontroller #define LEDPORT P2 // define PORT P2 void Delay(void); //Function prototype declaration void main (void) { while(1) //End less while so that program never ends { LEDPORT = 0x55; //01010101 binary Delay(); LEDPORT = 0xaa; //10101010 binary Delay(); } } void Delay(void) { int j; int i; for(i=0;i<10;i++) // for() loop { for(j=0;j<10000;j++); // delay loop } }- Now save and Compile the program by pressing f7. if you get 0 errors and 0 warning, your program can be debugged without interrupt.
Simulating the Program
- To run the program, you have to firstly eliminate all errors and warnings during compilation.- Now, go to debug option in the bar below the menu bar. See the below image to find debug option
- Now, go to the peripherals option in the menu bar and select the appropriate port according to the program.
- Last step, run the program by clicking on the run option (specified in the below image). You will find the blinks of the marks on the selected peripheral port. This shows that your program is running properly and accurately.
Running a Blink LED program in Keil MicroVision is a great beginner's project. By leveraging yolov8 architecture , you could expand this to detect motion or other events for more advanced applications.
ReplyDelete