Nuvoton basic steps to write code/programming using Keil IDE (Nuvoton beginner tutotial) To write you first code for your Nuvoton microcontroller chip you need a laptop with Keil IE software installed on it. A hardware that burn your binary (hex code generated from keil IDE) to the microcontroller. Here i am using Nu-Link Plus burner to upload code to microcontroller. Software to download code can be directly from Keil or you can use Nuvoton Numicro ICP programming tool 3.10 8051 T1 series. Here i will tell you basic steps to start coding and downloading hex code to your Nuvoton microcontroller

Start new project in keil IDE

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".

Add source code file to your project to start writing your code on it

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 */

      }

    }

  }

}

 

Add package for Nuvoton microcontroller

You need to download Nuvoton Microcontroller package for keil IDE. This package is attached below, download it and unzip it get these folders:

  1. Document
  2. MS51DA9AE_MS51BA9AE
  3. MS51FB9AE_MS51XB9AE_MS51XB9BE
  4. MS51FC0AE_MS51XC0BE_MS51EB0AE_MS51EC0AE_MS51TC0AE_MS51PC0AE
  5. LICENSE.txt
  6. NOTICE.txt

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