Open Keil IDE software and at to menu,click on project > new uvision project as shown in image below. Next you will ask to name a project to create a file to your folder. Then select your target microcontroller group/series and click ok. Then you will ask to Copy "MS51_STARTUP.A51" to project folder and add file to project, click on "yes".
Right click on source group 1 > add new item to source group 1 > select programming language (i am choosing c language here) and name your file anything but commonly named as main.c and click on "add". Then paste this code to the main.c file which is already created and open by you.
/* BLINKY.C - LED Flasher for the Keil MCBx51 Evaluation Board with 80C51 device*/
#include <REG51F.H>
// When you have enabled the option Stop Program Execution with Serial
// Interrupt, the Monitor-51 uses the serial interrupt of the UART.
// It is therefore required to reserve the memory locations for the interrupt
// vector. You can do this by adding one of the following code lines:
// char code reserve [3] _at_ 0x23; // when using on-chip UART for communication
// char code reserve [3] _at_ 0x3; // when using off-chip UART for communication
void wait (void) { /* wait function */
; /* only to delay for LED flashes */
}
void main (void) {
unsigned int i; /* Delay var */
unsigned char j; /* LED var */
while (1) { /* Loop forever */
for (j=0x01; j< 0x80; j<<=1) { /* Blink LED 0, 1, 2, 3, 4, 5, 6 */
P1 = j; /* Output to LED Port */
for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */
wait (); /* call wait function */
}
}
for (j=0x80; j> 0x01; j>>=1) { /* Blink LED 6, 5, 4, 3, 2, 1 */
P1 = j; /* Output to LED Port */
for (i = 0; i < 10000; i++) { /* Delay for 10000 Counts */
wait (); /* call wait function */
}
}
}
}
You need to download Nuvoton Microcontroller package for keil IDE. This package is attached below, download it and unzip it get these folders:
Copy these to a new folder name as "library" in your project folder. Then go to the target settings and click of "A51" tab and add link to the folder that contain LibraryDeviceInclude and LibraryStdDriverinc. as show in image bellow
Posted By :
Mahesh Nigam
(Scientist)
2023-05-01 01:51
See Author's other Published Topics
Peoples
Peoples
Comments...
Write Your Comment