完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
/*---------------------------------------------------------------------------------------------------------*/
/* */ /* 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 CONFIG program demo code //*********************************************************************************************************** #include "N76E003.h" #include "Common.h" #include "Delay.h" #include "SFR_Macro.h" #include "Function_define.h" /* Since the DATAFLASH is in the APROM. Program command is same as program APROM */ #define PAGE_ERASE_CF 0xE2 #define BYTE_READ_CF 0xC0 #define BYTE_PROGRAM_CF 0xE1 #define ERASE_FAIL 0x70 #define PROGRAM_FAIL 0x71 #define IAPFF_FAIL 0x72 #define IAP_PASS 0x00 /******************************************************************************************** Following IAP command register is also define in SFR_Macro.h #define set_IAPEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CHPCON |= SET_BIT0 ;EA=BIT_TMP #define clr_IAPEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;CHPCON &= ~SET_BIT0;EA=BIT_TMP #define set_CFUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN|=SET_BIT2;EA=BIT_TMP #define clr_CFUEN BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN&=~SET_BIT2;EA=BIT_TMP **********************************************************************************************/ void IAP_ERROR_LED(void) { while (1) { clr_P03; Timer0_Delay1ms(100); set_P03; Timer0_Delay1ms(100); } } //-----------------------------------------------------------------------------------------------------------/ void Trigger_IAP(void) { set_IAPGO; //trigger IAP if((CHPCON&SET_BIT6)==SET_BIT6) // if fail flag is set, toggle error LED and IAP stop { clr_IAPFF; IAP_ERROR_LED(); } } /* WARNING: No matter read or writer, when IAPFF is set 1, this step process is fail. DATA should be ignore. */ //-----------------------------------------------------------------------------------------------------------/ /***************************************************************************************************************** Write CONFIG subroutine: ******************************************************************************************************************/ void Enable_WDT_Reset_Config(void) { set_IAPEN; // Enable IAP function IAPAL = 0x04; IAPAH = 0x00; IAPFD = 0x0F; IAPCN = BYTE_PROGRAM_CF; set_CFUEN; // Enable CONFIG writer bit set_IAPGO; //trigger IAP while((CHPCON&SET_BIT6)==SET_BIT6); //check IAPFF (CHPCON.6) clr_CFUEN; clr_IAPEN; } //----------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------- void main (void) { Set_All_GPIO_Quasi_Mode; //---------toggle GPIO1--------- clr_GPIO1; Timer0_Delay1ms(100); set_GPIO1; Timer0_Delay1ms(100); clr_GPIO1; Timer0_Delay1ms(100); set_GPIO1; Timer0_Delay1ms(100); //---------end toggle GPIO1--------- Enable_WDT_Reset_Config(); while(1); } //----------------------------------------------------------------------------------------------------------- |
|
相关推荐
1个回答
|
|
sp; //在此略去若干字节*//*---------------------------------------------------------------------------------------------------------*/CMOD=!(CKCON & 0X40); //CMOD表示P16口的IO电平值 if(CMOD) PCLOUT = !PCLOUT; cap_ms = (CMOD ? (0xFFFF - capture_value + 1) / 11.0592 : capture_value / 11.0592); if(MODE == 2) time_count = cap_ms;/*------------------------------定时器1 配置------------------------------*/TMOD |= 0x10; //选择定时器1为模式1(16位定时器)TH1=(65535-(FOSC/(12*BAUDRATE)))>>8; //波特率重载值,高八位TL1=(65535-(FOSC/(12*BAUDRATE)))%256; //波特率重载值,低八位TR1 = 1; //启动定时器1异步工作 ET1 = 1; //开定时器1中断/*-----------------------------------------------------------------------------------*//*------------------------------定时器3 配置------------------------------*/SCON = 0X50; //方式1 TH3=(65535-(FOSC/(12*BAUDRATE)))>>8; //波特率重载值,高八位TL3=(65535-(FOSC/(12*BAUDRATE)))%256; //波特率重载值,低八位TR3 = 1; //启动定时器3异步工作 ET3 = 1; //开定时器3中断/*-----------------------------------------------------------------------------------*//*------------------------------键盘输入 配置------------------------------*/KBD_Func(); //键盘输入 初始化模块
上述代码部分涉及N76E003的定时器及键盘输入配置,与配置字无关,建议提供更具体的信息,以便得到更准确的回答。 |
|
|
|
只有小组成员才能发言,加入小组>>
3309 浏览 9 评论
2988 浏览 16 评论
3490 浏览 1 评论
9049 浏览 16 评论
4083 浏览 18 评论
1167浏览 3评论
601浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
592浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2329浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1892浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-18 15:35 , Processed in 1.349491 second(s), Total 83, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号