挖坑网/填坑网 DebugDump Forum

别人挖坑默默填上,自己挖坑含泪填上。天下没有填不了的坑,只有不会填坑的人。来吧,加入我们,挖坑行,填坑你更行! 站长QQ: 516333132 点击这里给我发消息

您尚未登录。

#1 2018-06-08 21:59:54

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

新唐 N76E003 8051 1T 单片机入坑记录

英文手册: DS_N76E003_EN_Rev0_04.pdf
中文手册: DS_N76E003_SC_Rev0_04.pdf


keil c51: c51v957.exe
破解补丁: KEIL_Lic.rar

开发板资料下载 QQ群附件: 623495321
开发板资料下载 链接: http://pan.baidu.com/s/1cCeT7g 密码:1n7f

开发板原理图: n76e003_sch.pdf

NU Link仿真器:
https://item.taobao.com/item.htm?id=562773467355

N76E003AT20开发板:
https://item.taobao.com/item.htm?id=562773539677

官方网站bsp下载: N76E003_BSP_Keil_C51_V1.0.5.zip


















QQ20180609154058.png

离线

#2 2018-06-08 22:01:50

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* Copyright(c) 2016 Nuvoton Technology Corp. All rights reserved.                                         */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/

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

//***********************************************************************************************************
//  File Function: N76E003 System clock select demo code
//***********************************************************************************************************

#include <stdio.h>
#include "N76E003.h"
#include "Common.h"
#include "Delay.h"
#include "SFR_Macro.h"
#include "Function_define.h"


//========================================================================
//  The test process:
//	1. Power on is run as default HIRC, show LED Fsys tickle faster
// 	2. toggle P3.0 to GND.
//	2. call modify Fsys code to LIRC.
//	3. LED tickle speed slowly than before.
//========================================================================
void main(void)
{

/* Note
  MCU power on system clock is HIRC (16 MHz)
	Please keep P3.0 HIGH before you want to modify Fsys to LIRC
*/
	
	  Set_All_GPIO_Quasi_Mode;                   	// In Common.h define
    set_CLOEN;    															// Also can check P1.1 CLO pin for clock to find the Fsys change.
		set_P30;
		while (P30)																	// when P3.0 keep high, clock out HIRC
		{   
				clr_GPIO1;															// Check LED output tickle time
        Timer0_Delay1ms(200);
        set_GPIO1;
        Timer0_Delay1ms(200);
		}
	
////------------------------------------------------------------------------------------------------------
///*********************************** Change system closk source ***************************************/
////------------------------------------------------------------------------------------------------------
              
////***** HIRC enable part *****               
//		set_HIRCEN;												//step1: enable HIRC clock source run
//		while((CKSWT&SET_BIT5)==0);				//step2: check ready
//		clr_OSC1;													//step3: switching system clock source if needed
//		clr_OSC0;
//		while((CKEN&SET_BIT0)==1);				//step4: check system clock switching OK or NG
//
////***** LIRC enable part*****
////** Since LIRC is always enable, switch to LIRC directly
		set_OSC1;													//step3: switching system clock source if needed
		clr_OSC0;  
		while((CKEN&SET_BIT0)==1);				//step4: check system clock switching OK or NG 	
		clr_HIRCEN;
   
////--------------------------------------------------------------------------------------------------------
    
/*
  Now Fsys = LIRC , LED tickle slowly.
*/
    while(1)
    {
				clr_GPIO1;															// Check LED output tickle time
        Timer0_Delay1ms(20);
        set_GPIO1;
        Timer0_Delay1ms(20);
    }
/* =================== */
}

时钟源:

  • – 16 MHz高速内部振荡器,电源5.0V条件下±1%精度等级。全工作条件范围±2%精度等级.

  • – 10 kHz低速内部振荡器.

  • – 支持外部时钟输入.

  • – 支持系统时钟即时软件切换(On-the-fly)功能.

  • – 支持软件配置时钟除频最高至1/512.

QQ20180608220354.jpg

QQ20180608220346.jpg

离线

#3 2018-06-08 22:20:49

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

QQ20180608222021.jpg

再次设置 CKDIV 分频器, 可以把10Khz 细分.


下面是系统频率FSYS计算公式:

当 CKDIV = 00H时,
Fsys =Fosc

当 CKDIV = 01H ~ FFH时,
Fsys = Fosc / (2 x CLKDIV)

上图是通过示波器测量 P1.1 (系统时钟输出脚) 引脚的波形和频率.


10000/(2*255) = 19.6 HZ

离线

#4 2018-06-08 22:34:23

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

这里有一个坑, 芯片只有 OSCIN(P3.0) 引脚, 没有 OSCOUT, 所以只能接有源晶振,不能接无源晶振。

离线

#5 2018-06-09 08:49:16

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

QQ20180609084746.png

使用内部10K赫兹, 255(0xFF)分频之后, 通过P1^5 口不断切换高低电平, 逻辑分析仪截图。

从板子上看 P1^5 引脚所接的 LED 1秒约闪两下.

离线

#6 2018-06-09 09:05:46

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

QQ20180609090412.png

QQ20180609090159.png

一直没有明白为什么上面的时钟周期是 7 : 4

后来经过Q群友提醒,while(1)跳转也需要指令周期, 查看 N76E003 手册指令周期表,

算出高电平的周期是 4 + 3(SJMP), 低电平周期 4

结果刚好是 7:4

离线

#7 2018-06-09 10:34:51

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

void main (void)
{
    InitialUART0_Timer3(9600);						//UART0 Baudrate from Timer3
    while(1)
    {
        Send_Data_To_UART0(0x33);
    }
}

上面的例程是 新唐提供 UART0 输出(P06, P07), 一切正常。

但是改成 UART1 之后就不行了。

void main (void)
{
    InitialUART1_Timer3(9600);						//UART0 Baudrate from Timer3
    while(1)
    {
        Send_Data_To_UART1(0x33);
    }
}

离线

#8 2018-06-09 10:36:25

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

QQ20180609103618.png

离线

#9 2018-06-09 11:07:45

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

QQ20180609110550.png



上图是 新唐官方例程 N76E003_BSP_Keil_C51_V0.04\Sample_Code\PWM_Simple\PWM.uvproj 逻辑分析仪抓图.

感觉 N76E003 的PWM只能设置为同一频率.

离线

#10 2018-06-09 11:51:16

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

1. 轮询模式发不出去
2. 中断模式无故进中断

N76E003 uart1(串口1) 真悲催.

离线

#11 2018-06-09 11:54:14

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

终于搞定了串口1问题,
原来是因为 UART1 与调试口复用,
拔了nu link就正常了。

离线

#12 2018-06-09 22:38:25

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* Copyright(c) 2016 Nuvoton Technology Corp. All rights reserved.                                         */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/

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

//***********************************************************************************************************
//  File Function: N76E885 ADC demo code
//***********************************************************************************************************

#include "N76E003.h"
#include "SFR_Macro.h"
#include "Function_define.h"
#include "Common.h"
#include "Delay.h"

//*****************  The Following is in define in Fucntion_define.h  ***************************
//****** Always include Function_define.h call the define you want, detail see main(void) *******
//***********************************************************************************************
#if 0
//#define Enable_ADC_BandGap	ADCCON0|=SET_BIT3;ADCCON0&=0xF8;																															//Band-gap 1.22V
#endif

double  Bandgap_Voltage,VDD_Voltage;			//please always use "double" mode for this
unsigned  char xdata ADCdataH[5], ADCdataL[5];
int ADCsumH=0, ADCsumL=0;
unsigned char ADCavgH,ADCavgL;

void READ_BANDGAP()
{
		UINT8 BandgapHigh,BandgapLow,BandgapMark;
		double Bandgap_Value,Bandgap_Voltage_Temp;
	
		set_IAPEN;
		IAPCN = READ_UID;
		IAPAL = 0x0d;
    IAPAH = 0x00;
    set_IAPGO;
		BandgapLow = IAPFD;
		BandgapMark = BandgapLow&0xF0;
			
		if (BandgapMark==0x80)
		{
				BandgapLow = BandgapLow&0x0F;
				IAPAL = 0x0C;
				IAPAH = 0x00;
				set_IAPGO;
				BandgapHigh = IAPFD;
				Bandgap_Value = (BandgapHigh<<4)+BandgapLow;
				Bandgap_Voltage_Temp = Bandgap_Value*3/4;
				Bandgap_Voltage = Bandgap_Voltage_Temp - 33;			//the actually banggap voltage value is similar this value.
		}
		if (BandgapMark==0x00)
		{
				BandgapLow = BandgapLow&0x0F;
				IAPAL = 0x0C;
				IAPAH = 0x00;
				set_IAPGO;
				BandgapHigh = IAPFD;
				Bandgap_Value = (BandgapHigh<<4)+BandgapLow;
				Bandgap_Voltage= Bandgap_Value*3/4;
		}
		if (BandgapMark==0x90)
		{
				IAPAL = 0x0E;
				IAPAH = 0x00;
				set_IAPGO;
				BandgapHigh = IAPFD;
				IAPAL = 0x0F;
				IAPAH = 0x00;
				set_IAPGO;
				BandgapLow = IAPFD;
				BandgapLow = BandgapLow&0x0F;
				Bandgap_Value = (BandgapHigh<<4)+BandgapLow;
				Bandgap_Voltage= Bandgap_Value*3/4;
		}
		clr_IAPEN;
//			printf ("\n BG High = %bX",BandgapHigh); 
//			printf ("\n BG Low = %bX",BandgapLow); 
//			printf ("\n BG ROMMAP = %e",Bandgap_Voltage); 
}
		
		
/******************************************************************************
The main C function.  Program execution starts
here after stack initialization.
******************************************************************************/
void main (void) 
{
		double bgvalue;
		unsigned int i;
	
		InitialUART0_Timer1(115200);

		READ_BANDGAP();
		Enable_ADC_BandGap;												

		CKDIV = 0x02;															// IMPORTANT!! Modify system clock to 4MHz ,then add the ADC sampling clock base to add the sampling timing.
		for(i=0;i<5;i++)													// All following ADC detect timing is 200uS run under 4MHz.
    {
			clr_ADCF;
			set_ADCS;																
      while(ADCF == 0);
			ADCdataH[i] = ADCRH;
			ADCdataL[i] = ADCRL;
 		}		
		CKDIV = 0x00;															// After ADC sampling, modify system clock back to 16MHz to run next code.
		
		for(i=2;i<5;i++)													// use the last 3 times data to make average 
    {
			ADCsumH = ADCsumH + ADCdataH[i];
			ADCsumL = ADCsumL + ADCdataL[i];
		}				
		ADCavgH = ADCsumH/3;
		ADCavgL = ADCsumL/3;
		bgvalue = (ADCavgH<<4) + ADCavgL;
		VDD_Voltage = (0x1000/bgvalue)*Bandgap_Voltage;
			printf (" BG ROMMAP = %f,",Bandgap_Voltage); 
			printf (" VDD voltage = %f\n", VDD_Voltage); 

    while(1);
}

上面这个是工程 N76E003_BSP_Keil_C51_V1.0.5\Sample_Code\ADC_Bandgap\ADC_Bandgap.uvproj 的代码,
用于测量单片机的工作电压,
运行结果

结果显示单片机工作电压 3112mV

BG ROMMAP = 1210.500000, VDD voltage = 3112.497000

换一个电源,测算出来 4722 mV

BG ROMMAP = 1210.500000, VDD voltage = 4722.103000

说明:

N76E003 ADC的第8通道是用来测试内部的带隙电压的,
由于内部带隙电压很稳定,
不会随芯片的工作电压的改变而变化,
所以可以通过测量带隙电压,
然后通过ADC的值便可反推出VCC的电压,
从而用户可以实现自己的低压检测功能。

Bandgap voltage reference,常常有人简单地称它为Bandgap。
是利用一个与温度成正比的电压与二极管压降之和,二者温度系数相互抵消,
实现与温度无关的电压基准。因为其基准电压与硅的带隙电压差不多,
因而称为带隙基准。实际上利用的不是带隙电压。
现在有些Bandgap结构输出电压与带隙电压也不一致。

离线

#13 2018-06-09 23:09:36

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* 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)
{
   
    P15_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 = 0x07; 										//timer base 10k, Pre-scale = 1/16
//		RWK = 0XFF;											//	if prescale is 0x00, never set RWK = 0xff
		RWK = 0xF0;
	  set_EWKT;													// enable WKT interrupt
		set_WKTR; 												// Wake-up timer run 
		EA = 1;
	
		while(1)
		{
			set_PD; //进入掉电模式
		}
}

QQ20180609230818.png

从这个工程修改: N76E003_BSP_Keil_C51_V1.0.5\Sample_Code\WakeupTimer_INT\WKT_INT.uvproj

N76E003 掉电模式与唤醒.

离线

#14 2018-06-09 23:28:07

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* 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 Read actual bandgap value by IAP command
//***********************************************************************************************************
#include "N76E003.h"
#include "Common.h"
#include "Delay.h"
#include "SFR_Macro.h"
#include "Function_define.h"

UINT8 UID_BYTE(UINT8 Addr)
{
		UINT8 DATATEMP;
		set_IAPEN;
		IAPAL = Addr;
    IAPAH = 0x00;
    IAPCN = READ_UID;
    set_IAPGO;
		DATATEMP = IAPFD;
		clr_IAPEN;
		return DATATEMP;
}

void main(void)
{
	UINT8 i = 0;
	UINT8 READ[12];
	Set_All_GPIO_Quasi_Mode;
	InitialUART0_Timer3(115200);
	
//---------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---------
	
	for(i=0;i<12;i++)
	READ[i] = UID_BYTE(i);

	
	while(1)
	{
			printf("UID: ");

			for(i=0;i<12;i++)
			{
					printf("%bx", READ[i]);
			}
			printf ("\n");
	}

}

工程: N76E003_BSP_Keil_C51_V1.0.5\Sample_Code\IAP_Read_UID\UID.uvproj
读 N76E003 96bit UID

输出结果:

UID: 223100455f3637afb00
UID: 223100455f3637afb00
UID: 223100455f3637afb00
UID: 223100455f3637afb00
UID: 223100455f3637afb00

离线

#15 2018-06-10 13:34:11

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

QQ20180610133202.png

打开 C:\Program Files (x86)\Nuvoton Tools\ICPTool\NuMicro ICP Programming Tool.exe 可执行程序,
按照上面5个步骤,
可以设置LDROM 4k, APROM 14k, 现在可以把程序烧到LDROM试一试了。

离线

#16 2018-06-10 16:59:07

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* 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 APROM program DATAFLASH (APROM) demo code
//***********************************************************************************************************

#include "N76E003.h"
#include "Common.h"
#include "Delay.h"
#include "SFR_Macro.h"
#include "Function_define.h"

#define     CID_READ            0x0B
#define     DID_READ            0x0C

/*
	Since the DATAFLASH is in the APROM. Program command is same as program APROM
*/
#define     PAGE_ERASE_LD       0x62
#define     BYTE_READ_LD        0x40
#define     BYTE_PROGRAM_LD	    0x61
#define     PAGE_SIZE           128


#define     ERASE_FAIL          0x70
#define     PROGRAM_FAIL        0x71
#define     IAPFF_FAIL          0x72
#define     IAP_PASS            0x00

//---------------------------------------------------------------
// Following define by customer
// Please confirm the start addresss not over your code size
//---------------------------------------------------------------
#define     DATA_SIZE           1024*4   
#define     DATA_START_ADDR     0x0000 					

/********************************************************************************************
 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_APUEN   BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN |= SET_BIT0 ;EA=BIT_TMP
	#define clr_APUEN   BIT_TMP=EA;EA=0;TA=0xAA;TA=0x55;IAPUEN &= ~SET_BIT0;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.
*/
//-----------------------------------------------------------------------------------------------------------/

/*****************************************************************************************************************
Erase APROM subroutine:
	

******************************************************************************************************************/		
void Erase_LDROM(void)
{   
    UINT16 u16Count;

    set_IAPEN;													// Enable IAP function
		IAPFD = 0xFF;												// IMPORTANT !! To erase function must setting IAPFD = 0xFF 
    IAPCN = PAGE_ERASE_LD;
    set_LDUEN;													//  APROM modify Enable
	
    for(u16Count=0x0000;u16Count<DATA_SIZE/PAGE_SIZE;u16Count++)		//
    {        
        IAPAL = LOBYTE(u16Count*PAGE_SIZE + DATA_START_ADDR);
        IAPAH = HIBYTE(u16Count*PAGE_SIZE + DATA_START_ADDR);
        Trigger_IAP(); 
    } 
//    clr_LDUEN;
//    clr_IAPEN;
}
//-----------------------------------------------------------------------------------------------------------
void Erase_LDROM_Verify(void)
{   
    UINT16 u16Count;
    set_IAPEN;
    IAPAL = LOBYTE(DATA_START_ADDR);
    IAPAH = HIBYTE(DATA_START_ADDR);
    IAPCN = BYTE_READ_LD;

    for(u16Count=0;u16Count<DATA_SIZE;u16Count++)
    {   
        IAPFD = 0x00;    
        Trigger_IAP();
        if(IAPFD != 0xFF)
					IAP_ERROR_LED();
        IAPAL++;
        if(IAPAL == 0x00)
          IAPAH++;
    } 
		
    clr_IAPEN;
    
}
//-----------------------------------------------------------------------------------------------------------
void Program_LDROM(void)
{   
    UINT16 u16Count;

    set_IAPEN;
    set_LDUEN;    
    IAPAL = LOBYTE(DATA_START_ADDR);
    IAPAH = HIBYTE(DATA_START_ADDR);
    IAPCN = BYTE_PROGRAM_LD;
    
    for(u16Count=0;u16Count<DATA_SIZE;u16Count++)
    {   
        IAPFD++;     
        Trigger_IAP();
       
        IAPAL++;
        if(IAPAL == 0)
        {
            IAPAH++;
        }
    } 
		
    clr_LDUEN;
    clr_IAPEN;
}
//-----------------------------------------------------------------------------------------------------------
void Program_LDROM_Verify(void)
{   
    UINT16 u16Count;
    UINT8  u8Read_Data;

    set_IAPEN;
    IAPAL = LOBYTE(DATA_START_ADDR);
    IAPAH = HIBYTE(DATA_START_ADDR);
    IAPCN = BYTE_READ_LD;
    u8Read_Data = 0x00;

    for(u16Count=0;u16Count<DATA_SIZE;u16Count++)
    {   
        Trigger_IAP();
        if(IAPFD != u8Read_Data)
					IAP_ERROR_LED();
        IAPAL++;
        if(IAPAL == 0)
        {
            IAPAH++;
        }
        u8Read_Data ++;
    } 

    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---------
	
    Erase_LDROM();
		Erase_LDROM_Verify();
    Program_LDROM();
    Program_LDROM_Verify();

//---------toggle GPIO1---------	
	clr_GPIO1;
//---------end toggle GPIO1---------

    while(1);
}
//-----------------------------------------------------------------------------------------------------------

N76E003_BSP_Keil_C51_V1.0.5\Sample_Code\IAP_AP-program-LD\IAP_APproLD.uvproj

这个例程演示的是在程序中(APPROM)编程 LDROM区域

QQ20180610165813.png

用烧写器把LDROM读出来验证确实编程成功了!

离线

#17 2018-06-11 11:59:11

晕哥
Administrator
注册时间: 1970-01-01
累计发帖: 2,505

Re: 新唐 N76E003 8051 1T 单片机入坑记录

QQ20180611115740.jpg

担心中途又烧板子,又淘了 5块N76E003板子,一个新唐 nu-link仿真器.

离线

页脚