Getting Started with Nuvoton 8-bit Microcontrollers

Many of us who are involved in the embedded system industry like 8-bit microcontrollers. They are cheap, easy to use and solve most of the common automation problems. 32-bit micros are in that contrast expensive and are mainly intended for advance-level works that cannot be solved with 8-bit micros. Thus, 32-bit micros are not much demanding as the 8-bit ones. In most places, 8051s, AVRs and PICs are the most used 8-bit micros. The popular Arduino platform is mainly based on 8-bit AVR micros. However, these are not the only 8-bit micros of the whole embedded world. Nuvoton – a Taiwan-based semiconductor manufacturer, is one such company that has its own flavour of 8-bit and 32-bit micros. The 8-bit micros from Nuvoton are based on the popular 8051 architectures. In this series of articles, we will be discovering Nuvoton N76E003 1T-8051-based microcontroller.

SDK

N76E003 vs STM8S003

Hardware Internals

In terms of outlook, part numbering, pin layout and other basic features, N76E003 looks like a cheap Chinese copy of STMicroelectronics’ STM8S003. However, as we all know, looks can be deceptive. Though several similarities, N76E003 is not a replica of STM8S003 in any way. In fact, in terms of architecture and some hardware features, N76E003 varies a lot from STM8S003. For instance, the processor core of these chips is not same. Even after having same pin layouts, N76E003 has several additional hardware than STM8S003, for instance 8 channel – 12-bit ADC.

ST Vs Nu

The table below summarizes an actual comparison of these chips.

Features

It is a good idea to consider N76E003 as an advanced 8051 micro in STM8S003 form-factor and having several similarities with the STM8S003.

Hardware Tools

To get started only two things are needed – a prototyping/development board and a programmer called NuLink.  There are two options either you can buy the expensive official NuTiny SDK boards with built-in NULink programmer/debugger or you can buy the cheap unofficial ones as shown below.

programmer + board

My personal choice is the unofficial one.

 

Software Tools

Despite Nuvoton being a giant in manufacturing some of the industry’s coolest chips, it greatly lags in terms of software tools. Unlike other manufacturers like STMicroelectronics and Microchip, Nuvoton doesn’t have a free C compiler of its own. To use Nuvoton 8-bit micros, we have to use either Keil Micro Vision or IAR Embedded Workbench. Both industry-standard tools but are not free. However, there are trial and evaluation versions of these tools.

keil vs iar

The next stuffs that we will be needing are device datasheet, drivers, GUI for NuLink and sample codes with Nuvoton’s official header and source files. These are available here.

 

We will also be needing a pin map because there are few pins in N76E003 and they have multiple functions.

N76E003

How to get started?

I have made two videos – one for Keil and the other for IAR. These videos show in details how to start building projects with N76E003 using these compilers.

 

Nuvoton Files

No matter which compiler you use ultimately, you’ll need the following header (.h) and source files (.c) to get things done properly. These are available in Keil BSP and IAR BSP zip files.

Files

Now what these files do? These files make up something like a standard peripheral library. They define registers and functions that are needed to simplify coding. These files replace tradition register-level access to meaningful codes. For instance, the Delay files dictate the software delay functions by using hardware timers. Likewise, SFR_Macro and Function_Define files define hardware-based functions and SFR uses. I highly recommend going through the files.

Related Posts

57 comments

  • Hello Shawon, call me stupid but I don’t get it. When you can program all MCS51 units like Atmel’s S51, STC and WCH uCs with 2 dollar USB to UART or simply UART level converters or even just USB in case of WCH – Why** a 1 dollar Nuvoton uC neeeds the 10 dollar NuLink board – yes and I’m talking about the unofficial “cheap” programmer – to program it?
    I wanted to try out a 1 dollar n76e003at20 board off Ali but when I found that it needs a 10 dollar NuLink box I now think: would it be better to stick with the WCH stuff which is similarly priced? What would be the reason to persuade oneself to spend 10 times more on the programmer for a simple MCS51 unit? Pure curiosity in search for what?

  • Hello,

    I’m trying to implement GLCD on nuvoton ml54 but it’s not running here i’m attaching my code can anyone help me??

    #include “ml54.h”
    //#include

    /********************DEFINE IO********************/
    #define LCD_GPIO_init() do{P00_PUSHPULL_MODE; P01_PUSHPULL_MODE; P02_PUSHPULL_MODE; P03_PUSHPULL_MODE; P04_PUSHPULL_MODE; P10_PUSHPULL_MODE; P11_PUSHPULL_MODE; P12_PUSHPULL_MODE; P13_PUSHPULL_MODE; P14_PUSHPULL_MODE; P15_PUSHPULL_MODE; P16_PUSHPULL_MODE; P17_PUSHPULL_MODE;}while(0)

    #define CD_High set_P3_0 // COMMAND/DATA
    #define CD_Low clr_P3_0 // COMMAND/DATA

    #define RESET_High set_P3_1 // RESET
    #define RESET_Low clr_P3_1 // RESET

    #define FS_High set_P3_3 // 8*8 16*8
    #define FS_Low clr_P3_3 // 8*8 16*8

    #define _WR_High set_P3_6 // WRITE
    #define _WR_Low clr_P3_6 // WRITE

    #define _RD_High set_P3_7 // READ
    #define _RD_Low clr_P3_7 // READ

    //TP CHIP IO
    #define DCLK_High set_P2_0
    #define DCLK_Low clr_P2_0

    #define TP_CS_High set_P2_1
    #define TP_CS_Low clr_P2_1

    #define DIN_High set_P2_2
    #define DIN_Low clr_P2_2

    #define BUSY_High set_P2_3
    #define BUSY_Low clr_P2_3

    #define DOUT_High set_P2_4
    #define DOUT_Low clr_P2_4

    #define uchar unsigned char
    #define uint unsigned int
    #define DataBus P1
    #define Graphic 1
    #define Character 0

    uint TP_X=0;uint TP_Y=0; //LOCATE X AND Y OF TP

    unsigned char code BMP1[];

    void Locatexy(uchar xa,uchar ya,uchar mode);
    void CheckBusy_S0S1();
    void CheckBusy_S3();
    void WriteCommand(uchar dat1,uchar dat2,uchar command,uchar parameters_num);
    void WriteData(uchar DataByte);
    void LcmClear();
    void Display_Str(uchar x,uchar y,uchar *ascll);
    void LcmInit();
    void Delay(uint MS);
    void spistar();

    /************************TP*************************/
    //**********************************************************
    void spistar() //SPI START
    {
    TP_CS_High;
    DCLK_High;
    DIN_High;
    DCLK_High;
    }

    // LOCATE X AND Y OF LCM
    void Locatexy(uchar xa,uchar ya,uchar mode)
    { uint a=0;
    if(mode) //Graphic mode x=0-29 y=0-127 START ADDRESS ??0800
    {
    a=ya*30+xa;
    WriteCommand((uchar)a,(uchar)(a>>8)+0x08,0x24,2);
    }

    else //Character mode x=0-29 y=0-15 START ADDRESS ??0000
    {
    a=ya*30+xa;
    WriteCommand((uchar)(a),(uchar)(a>>8),0x24,2);
    }

    }

    /*LCM READ AND WRITE BUSY CHECK */

    void CheckBusy_S0S1()
    {
    uchar b;
    do
    {
    DataBus=0x00;
    CD_High;
    _RD_Low;
    b=DataBus;
    _RD_High;
    }while(b&0x03!=0x03);

    }

    /*DATA AUTO WRITE BUSY CHECK */

    void CheckBusy_S3()
    {
    uchar b;
    do
    {
    DataBus=0x00;
    CD_High;
    _RD_Low;
    b=DataBus;
    _RD_High;
    }while(b&0x08!=0x08);
    }

    /*WRITE COMMAND */
    void WriteCommand( uchar dat1,uchar dat2,uchar command,uchar parameters_num )
    {
    if((parameters_num==1)|(parameters_num==2))
    {
    CheckBusy_S0S1();
    WriteData(dat1);
    }
    if(parameters_num==2)
    {
    CheckBusy_S0S1();
    WriteData(dat2);
    }

    CheckBusy_S3();
    CD_High;
    DataBus = command;
    _WR_Low;
    Delay(1);
    // _nop_();
    _WR_High;
    }

    /*WRITE DATA */
    void WriteData(uchar DataByte)
    {
    CD_Low;
    DataBus = DataByte;
    _WR_Low;
    Delay(1);
    //_nop_();
    _WR_High;
    }

    void LcmClear()
    { uint a;
    Locatexy(0,0,Character);
    WriteCommand(0,0,0xb0,0 );
    for(a=0;a0)
    {
    WriteCommand(*ascll-0x20,0,0xc0,1 );
    ascll++;
    }
    }

    //void Delay(uint MS)
    //{
    // unsigned char us,usn;
    // while(MS!=0)
    // {
    // usn = 2; //for 12M
    // while(usn!=0)
    // {
    // us=0xf6;
    // while (us!=0){us–;};
    // usn–;
    // }
    // MS–;
    // }
    //}
    void Delay(uint time)
    {
    uint i,j;
    for(i=0;i<time;i++)
    {
    for(j=0;j<1275;j++);
    }
    }
    void LcmInit()
    {
    //Delay(50);

    RESET_Low;
    Delay(10);
    RESET_High;
    Delay(10);
    LCD_GPIO_init();
    WriteCommand(0,0,0×40,2);
    WriteCommand(30,0,0×41,2);
    WriteCommand(0,0×08,0x42,2);
    WriteCommand(30,0,0×43,2);
    WriteCommand(0,0,0xa7,0);
    WriteCommand(0,0,0×80,0);
    WriteCommand(0,0,0x9c,0);
    }
    void Main()
    {
    uchar flag=1;uint dnum=0;// uchar ss[6];
    // ALL_GPIO_PUSHPULL_MODE;
    P0=0x00;
    P1=0x00;
    P2=0x00;
    P3=0x00;

    //P0=0xff;
    FS_Low;

    spistar();
    LcmInit();

    LcmClear();
    Display_Str(2,4,"LEONS INTEGRATION PVT LTD.");
    Display_Str(11,6,"MADE BY");
    Display_Str(7,9,"PankaJ");
    Display_Str(14,9,"Kushwaha");
    while(1) ;
    {

    // Delay(1000);
    // LcmClear();
    }
    }

  • Rushvinkumar KAKANI

    i want to start communication USING usart 1,2,3 in MS51PC0AE WHIT=CH IS 32 PIN AND 32K IC
    but cant get result. Can you please send me some program for that

  • hello sir, I am trying to drive two motor with the help of nuvoton controller N76E003 and DRV8833 Motor driver i need help with code because I have tried so many times. we need to change PWM with respect to duty cycle

  • How i can use ir remote with nuvoton letest low power series ml51fb9ae.

  • Hello sir… I am trying to use both the UART port (UART0 & UART1) of n76E003 simultaneously, on receive interrupt. Individually both the ports works fine, but together only one port works & other remain silent or give garbage data. I tried by enabling and setting the priority bits, but again the port with high priority works fine and other remain silent.

  • Sir,
    Do you have PDF file of above tutorials?!
    Kindly provide.
    Thanks and Regards
    Kumar KS

  • Can I use 38400 baud rate detection in Nuvoton N76E003 microcontroller for serial communication and what steps can I use to achieve this?

  • Can I use 38400 baud rate detection in Nuvoton N76E3003 microcontroller for serial communication and what steps can I use to achieve this?

  • Hi,
    I have been learning a lot from your posts. I am working on a college project Digital AC Volt and Amp Meter. The circuit basically reads ADC voltages for Voltage and Current. I am successfully able to read the ADC values, thanks to your posts. However, the circuit uses Capacitor based supply and hence the VDD changes in accordance with the AC Supply Voltage. I read about the internal BandGap voltage and that it remains constant throughout but I am unable to figure out how to use that to calculate VDD, hence the Vref+.

  • I sent accidentally 2 comments about the same subject.You can delete one of them or both of them.:)

  • Which is the best Nuvoton make programmer for the complete range of Nuvoton ms51 series 8 bit microcontrollers
    Thanks
    Regards
    BJ Hari charan

  • How to upload code using UART ?

    N76E003AT20 supports (In-System Programming); ICP (In-Circuit Programming); IAP (In-Application Programming).

  • thanks sir!

  • Hello sir,

    your work has been phenomenal and really helpful, I have bought MS51FB9AE whose pin out is pretty much the same as N76E003.
    I wanted to know if all those header files,codes that you’ve used on N76E003 could be used for MS51FB9AE also?

    and if you have any sources or tutorials for MS51FB9AE, please help me out with it.

    • No, they are different in many ways and so same BSP files won’t work. Nuvoton sent me MS51 and several other boards for evaluation but they have not released any BSP for those and things got worse due to COVID-19. I guess we would have to break through this by going through the reference manuals and building BSPs on our own.

    • Well, i had used your codes and Headers for programming MS51FB9AE, But as you said…..it resemble quite same but there is lot of changes that are needed in the library and i am kind of stucked….. However they have provided me the BSP files but still i am struggling……

      So far Blinking LED is working, But i need to interface mlx90614 with LCD using MS51FB9AE, So if you have any suggestions or references…please do share.

  • KRISHAN KUMAR CHAUHAN

    @Shawon Shahryiar wanted to talk to you and seeking help from you..how can I contact you???

  • Dear,

    I’m new in nuvoton..
    I use cheap unofficial Nu-Link like u. Is it safe to update nulink firmware without any issue?
    When not updating, all is well

  • hi,

    i want to store data or value in n76e003 internal memory, please guide me. my email :uddhavkumbhar94@gmail.com

  • Excellent tutorial. Can you please guide me how to install the Nueclipse IDE & use your code?

  • Hello… I am trying to use both the UART port (UART0 & UART1) of n76E003 simultaneously, on receive interrupt. Individually both the ports works fine, but together only one port works & other remain silent or give garbage data. I tried by enabling and setting the priority bits, but again the port with high priority works fine and other remain silent. Please help to solve the issue….

  • Is it possible to dump the firmware of a N76 usig the NU-Link?

    Thanks!

  • hi
    I have a lot of interest to learn N76E003.
    But I do not know where to start …
    i worked Franklin , Codevision , bascome …. but very different IAR or Kail …
    Two films above will not open for me .
    send FOR me links , thanked you

  • Jitender Singh saggu

    Hi, Thanks for a very interesting comparison. i wanted to know the code compactness difference between these two controller for the same code .
    Thanks

    • This difference should not be made because STM8s use separate set of tools unlike IAR or Keil for Nuvoton…. Though IAR does support STM8, it would be unwise to compare Nuvoton with STM8 in coding arena because these are chips employing different architectures/cores, instruction sets and different strategies….

  • Are there any universal programmers which can be used to program Nuvoton Microcontrollers?

    • The aforementioned programmer is an universal Nuvoton programmer…. But I haven’t seen any other universal programmer that supports Nuvoton micros….

    • There are two type programmer in Nuvoton,
      One of them Standart 5V programmer, it can only program 5V VDD supported products.
      Other of them is changable voltage programmer, it can program all nuvoton products.

  • Can you give link of the cheap unofficial Nu link programmer? And can we program it without this particular programmer? Just trying to find a cheaper alternative to this programmer.

  • Santosh Kharade

    Its a good for a beginner………keep it up and provide this type of solution to us……….thank you

  • It is so useful topic. But i look into Nuvoton’s website Nuvoton have Cortex M0 and Cortex M4 family. It will be good if you can compare STM32 with Nuvoton different MCU family ( M0, M4) 🙂

    Also It will be good if you can compare Nuvoton Vs Microchip 🙂

    I am following you about it.

    Best regards,

  • I’ve been following these chip line closely, because they are good value for the money. Hoping you will have several articles with the Nuvoton 8-bit family in application? Thanks for an excellent introduction.

    R.

Leave a Reply to Shawon Shahryiar Cancel reply

Your email address will not be published. Required fields are marked *