打印
[DemoCode下载]

003的唤醒定时器作为中断使用

[复制链接]
266|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jiekou001|  楼主 | 2019-9-29 23:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
如果想使用唤醒定时器作为一个普通定时器用于中断怎么弄呢?

使用特权

评论回复
沙发
jiekou001|  楼主 | 2019-9-29 23:47 | 只看该作者
/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* Copyright(c) 2017 Nuvoton Technology Corp. All rights reserved.                                         */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/

//***********************************************************************************************************
//  Nuvoton Technoledge Corp.
//  Website: http://www.nuvoton.com
//  E-Mail : MicroC-8bit@nuvoton.com
//  Date   : Apr/21/2017
//***********************************************************************************************************

//***********************************************************************************************************
//  File Function: N76E003 wake up timer interrupt demo code
//***********************************************************************************************************
#include "N76E003.h"
#include "Common.h"
#include "Delay.h"
#include "SFR_Macro.h"
#include "Function_define.h"

void WakeUp_Timer_ISR (void)   interrupt 17     //ISR for self wake-up timer
{
                clr_GPIO1;
                Timer1_Delay10ms(5);
                set_GPIO1;
                Timer1_Delay10ms(5);
                clr_GPIO1;
                Timer1_Delay10ms(5);
                set_GPIO1;
          clr_WKTF;                                               //clear interrupt flag   
}


/************************************************************************************************************
*    Main function
************************************************************************************************************/
void main (void)
{
   
    P12_PushPull_Mode;

                clr_GPIO1;
                Timer0_Delay1ms(400);
                set_GPIO1;
                Timer0_Delay1ms(400);
                clr_GPIO1;
                Timer0_Delay1ms(400);
                set_GPIO1;
                Timer0_Delay1ms(400);
                clr_GPIO1;
                Timer0_Delay1ms(400);
                set_GPIO1;

//-----------------------------------------------------
//        WKT initial        
//-----------------------------------------------------       
                WKCON = 0x02;                                                                                 //timer base 10k, Pre-scale = 1/16
//                RWK = 0XFF;                                                                                        //        if prescale is 0x00, never set RWK = 0xff
                RWK = 0X00;
          set_EWKT;                                                                                                        // enable WKT interrupt
                set_WKTR;                                                                                                 // Wake-up timer run
                EA = 1;
       
                while(1);
}

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

124

主题

1259

帖子

2

粉丝