Nuvoton N76e003 MCU Program Analysis

Publisher:文江桂青Latest update time:2022-07-08 Source: csdnKeywords:Nuvoton Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In the Function_define.h file


#ifdef FOSC_160000 // if Fsys = 16MHz 

 

#define TIMER_DIV12_VALUE_10us 65536-13 //13*12/16000000 = 10 uS,  // Timer divider = 12 for TM0/TM1

#define TIMER_DIV12_VALUE_100us 65536-130 //130*12/16000000 = 10 uS,  // Timer divider = 12 

#define TIMER_DIV12_VALUE_1ms 65536-1334 //1334*12/16000000 = 1 mS,  // Timer divider = 12 

16M clock, after 12 division, the timer period is 16/12 us, so 1ms=1000*16/12 is about 1334




Each unit is 1ms


void Timer0_Delay1ms(UINT32 u32CNT)

{

    clr_T0M;                                //T0M=0, Timer0 Clock = Fsys/12 Timer 0 12 division

    TMOD |= 0x01;                            //Timer0 is 16-bit mode 16-bit timer/counter

    set_TR0;                                //Start Timer0

    while (u32CNT != 0)

    {

        TL0 = LOBYTE(TIMER_DIV12_VALUE_1ms); //Find  define in "Function_define.h" "TIMER VALUE"

        TH0 = HIBYTE(TIMER_DIV12_VALUE_1ms); //Set the corresponding values ​​for the high 8 bits and the low 8 bits

        while (TF0 != 1);                    //Check Timer0 Time-Out Flag Wait for overflow

        clr_TF0; //Clear overflow

        u32CNT--;

    }

    clr_TR0;                                //Stop Timer0 Timer 0 stops

}


Keywords:Nuvoton Reference address:Nuvoton N76e003 MCU Program Analysis

Previous article:Nuvoton MS51FB9AE development environment construction
Next article:N76E003AT20 MCU serial port 0 debugging

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号