mc8051用户手册中文版
8051微控制器硬件手册及应用注释说明书

1API Program ExamplesReferences•Atmel 8051 Microcontrollers Hardware Manual1. IntroductionThis Application Note provides to customers C program examples for Api usages.24365A–80C51–07/0434365A–80C51–07/042. API for Standard C512.1 flash_eeprom_api.c/*C************************************************************************ NAME: flash_eeprom_api.c*-------------------------------------------------------------------------* Copyright (c) 2004 Atmel.*-------------------------------------------------------------------------* RELEASE:* REVISION: 1.0*-------------------------------------------------------------------------* PURPOSE:* Read/Write flash* CAUTTION : add #define ONCHIP_EEPROM for on-chip eeprom products* (defined by default in the standard delivery)**************************************************************************//*_____ I N C L U D E - F I L E S _______________________________________*/#include "reg_C51.h"/*_____ D E C L A R A T I O N ___________________________________________*/#define ONCHIP_EEPROM //define it only for on-chip eeprom products/*---- API for FLASH access --------------------------------------------*//*************************************************************************/#define __api_rd_code_byte(address) (*((unsigned char code*) (address)))unsigned char__api_wr_code_byte(int , unsigned char)small;unsigned char__api_wr_code_page(int , int, unsigned char)small;/*---- API for EEPROM access -------------------------------------------*//*************************************************************************/#ifdef ONCHIP_EEPROMvoid __api_wr_eeprom_byte(unsigned int adr, unsigned char value);unsigned char __api_rd_eeprom_byte(unsigned int adr);#endif/*_____ G L O B A L S ___________________________________________________*/sfr16 DPTR = 0x82;/*_____ L O C A L S _____________________________________________________*/#define MSK_AUXR1_ENBOOT0x20#define MSK_AUXR_M00x20#define MAP_BOOT AUXR1 |= MSK_AUXR1_ENBOOT;#define UNMAP_BOOTAUXR1 &= ~MSK_AUXR1_ENBOOT;/*_____ EXTERNAL - F U N C T I O N S - D E C L A R A T I O N ____________*/extern void ASM_MOV_R1_A(void);extern void __API_FLASH_ENTRY_POINT(void);/*F************************************************************************ NAME: __api_wr_code_byte*-------------------------------------------------------------------------* PARAMS:* int address : address to program* unsigned char value : data to write* unsigned char return :* return = 0x00 -> pass* return != 0x00 -> fail*-------------------------------------------------------------------------* PURPOSE:* Program data byte in Flash memory**************************************************************************/unsigned char __api_wr_code_byte (int address, unsigned char value) small{bit ea_save;ea_save = EA;EA = 0;DPTR = address;ACC = 0x02;ASM_MOV_R1_A();ACC = value;MAP_BOOT;__API_FLASH_ENTRY_POINT();UNMAP_BOOT;EA = ea_save; // restore interrupt statereturn (ACC);}/*F************************************************************************ NAME: __api_wr_code_page*-------------------------------------------------------------------------* PARAMS:* int add_flash : address of the first byte to program in the Flash* int add_xram : address in XRAM of the first data to program* unsigned char nb_data : number of bytes to program*unsigned char return :* return = 0x00 -> pass* return != 0x00 -> fail*-------------------------------------------------------------------------* PURPOSE:* Program until 128 Datas in Flash memory.* Number of bytes to program is limited such as the Flash write remains in a* single 128 bytes page.**************************************************************************/unsigned char __api_wr_code_page (int add_flash, int add_xram, unsigned charnb_data) small{unsigned char save_auxr1;bit ea_save;44365A–80C51–07/0454365A–80C51–07/04ea_save = EA;EA = 0;save_auxr1 = AUXR1;AUXR1 &= ~0x01; // Set DPTR=DPTR0DPTR = add_flash;AUXR1++; // DPTR = DPTR1DPTR = add_xram;ACC = 0x09;ASM_MOV_R1_A();ACC = nb_data;AUXR1 &= ~0x01; // Set DPTR = DPTR0MAP_BOOT__API_FLASH_ENTRY_POINT();UNMAP_BOOT;AUXR1 = save_auxr1;EA = ea_save; // restore interrupt statereturn (ACC);}/*F************************************************************************ NAME: __api_rd_eeprom_byte*-------------------------------------------------------------------------* PARAMS:* unsigned int adr: The EEDATA memory location to read* return: value*-------------------------------------------------------------------------* PURPOSE:* This function reads one byte in the on-chip EEPROM data.*-------------------------------------------------------------------------* EXAMPLE:* val=__api_rd_eeprom_byte(128);*-------------------------------------------------------------------------* NOTE:*-------------------------------------------------------------------------* REQUIREMENTS:**************************************************************************/unsigned char __api_rd_eeprom_byte(unsigned int adr){unsigned char val;bit ea_save;while (EECON&1);//Eeprom_busy()ea_save=EA;EA=0;EECON |= 0x02;//Enable eeprom data;val=*(unsigned char xdata*)adr;EECON &= ~0x02;//Disable eeprom data;EA=ea_save;return val;}/*F************************************************************************ NAME: __api_wr_eeprom_byte*-------------------------------------------------------------------------* PARAMS:* unsigned int adr: The EEDATA memory location to read* unsigned char value: The data byte to write* return: none*-------------------------------------------------------------------------* PURPOSE:* This function writes one byte in the on-chip EEPROM data.*-------------------------------------------------------------------------* EXAMPLE:*-------------------------------------------------------------------------* NOTE:*-------------------------------------------------------------------------* REQUIREMENTS:**************************************************************************/void __api_wr_eeprom_byte(unsigned int adr, unsigned char value){bit ea_save;while(EECON & 0x01);// wait bit busyea_save=EA;EA=0;EECON |= 0x02;//Enable eeprom data*(unsigned char xdata*)adr=value;EECON &= ~0x02;//Disable eeprom dataEA=ea_save;}64365A–80C51–07/0474365A–80C51–07/042.2 flash_lib.a51NAME FLASH_LIB;;*A51********************************************************************; FILE_NAME : FLASH_LIB.a51 ;------------------------------------------------------------------------ ;------------------------------------------------------------------------; FILE_PURPOSE: low level function for API;************************************************************************USING 0PUBLIC ASM_MOV_R1_APUBLIC __API_FLASH_ENTRY_POINTAUXR1 EQU0A2hSTART SEGMENT CODERSEG START;************************************************************************; FUNCTION_NAME: ASM_MOV_A_R1;************************************************************************ASM_MOV_R1_A:Mov R1, ARet;************************************************************************; FUNCTION_NAME: __API_FLASH_ENTRY_POINT;************************************************************************__API_FLASH_ENTRY_POINT:PUSHAR2PUSHAR4PUSHAR6LCALL 0FFF0hPOPAR6POPAR4POPAR2RetEND3. API for USB products3.1 flash_eeprom_api.c/*C************************************************************************ NAME: flash_eeprom_api.c*-------------------------------------------------------------------------* Copyright (c) 2004 Atmel.*-------------------------------------------------------------------------* RELEASE:* REVISION:*-------------------------------------------------------------------------* PURPOSE:* This file contains whole of functions to access AT89C5131 Flash and* EEPROM and AT89C51SND1.* CAUTTION : add #define ONCHIP_EEPROM for on-chip eeprom products* (defined by default in the standard delivery)**************************************************************************//*_____ I N C L U D E S _________________________________________________*/#include "reg_C51.h"/*_____ D E F I N I T I O N _____________________________________________*/#define ONCHIP_EEPROM //define it only for build-in eeprom chipsunsigned char data api_command _at_ 0x1C;unsigned char data api_value _at_ 0x1D;#define MSK_AUXR1_ENBOOT 0x20#define MAP_BOOT AUXR1 |= MSK_AUXR1_ENBOOT;#define UNMAP_BOOT AUXR1 &= ~MSK_AUXR1_ENBOOT;#define __API_FLASH_ENTRY_POINT (*((const void(code*)(void)) 0xFFC0 ))/*_____ D E C L A R A T I O N ___________________________________________*//*---- API for FLASH access --------------------------------------------*//*************************************************************************/unsigned char __api_rd_code_byte (unsigned char code * pt_address);unsigned char __api_wr_code_byte (unsigned char xdata* , unsigned char);unsigned char __api_wr_code_page (unsigned char xdata* pt_code,unsigned char xdata* pt_xram,unsigned char nb_data);/*---- API for EEPROM access -------------------------------------------*//*************************************************************************/#ifdef ONCHIP_EEPROMunsigned char __api_rd_eeprom_byte(unsigned char xdata *);unsigned char __api_wr_eeprom_byte(unsigned char xdata *, unsigned char);#endif84365A–80C51–07/0494365A–80C51–07/04/*F************************************************************************ NAME: __api_rd_code_byte*-------------------------------------------------------------------------* PARAMS:* unsigned int address : address in flash memory to read* return:* unsigned char device : read value*-------------------------------------------------------------------------* PURPOSE:* This function allows to read a flash memory byte.*-------------------------------------------------------------------------* EXAMPLE:*-------------------------------------------------------------------------* NOTE:*-------------------------------------------------------------------------* REQUIREMENTS:**************************************************************************/unsigned char __api_rd_code_byte (unsigned char code * pt_address){return(*pt_address);}/*F************************************************************************ NAME: __api_wr_code_byte*-------------------------------------------------------------------------* PARAMS:* unsigned int address : address to program* unsigned char value : data to write* return:* unsigned char return :* return = 0x00 -> pass* return != 0x00 -> fail*-------------------------------------------------------------------------* PURPOSE:* This function allows to program data byte in Flash memory.*-------------------------------------------------------------------------* EXAMPLE:*-------------------------------------------------------------------------* NOTE:*-------------------------------------------------------------------------* REQUIREMENTS:**************************************************************************/unsigned char __api_wr_code_byte (unsigned char xdata * pt_address, unsigned char value){bit ea_save;ea_save = EA;EA = 0;api_command = 0x0D; //_COMMAND_WR_CODE_BYTE;FCON = 0x08;*pt_address = value;MAP_BOOT;__API_FLASH_ENTRY_POINT();UNMAP_BOOT;EA = ea_save; // restore interrupt statereturn(api_value);}/*F************************************************************************ NAME: __api_wr_code_page*-------------------------------------------------------------------------* PARAMS:* unsigned int add_flash : address of the first byte to program* in the Flash* unsigned int add_xram : address in XRAM of the first data to program* unsigned char nb_data : number of bytes to program* return:* unsigned char return :* return = 0x00 -> pass* return != 0x00 -> fail*-------------------------------------------------------------------------* PURPOSE:* This function allows to program until 128 Datas in Flash memory.* Number of bytes to program is limited such as the Flash write remains* in a single 128 bytes page.*-------------------------------------------------------------------------* EXAMPLE:*-------------------------------------------------------------------------* NOTE:* This function used Dual Data Pointer DPTR0&1. At the end of this* function.* DPTR = DPTR0.*-------------------------------------------------------------------------* REQUIREMENTS:**************************************************************************/unsigned char __api_wr_code_page (unsigned char xdata * pt_code,unsigned char xdata * pt_xram,unsigned char nb_data){unsigned char data i, temp, temp_nb_data;bit ea_save;unsigned int data add_pt_code, add_pt_xram;add_pt_xram = pt_xram;add_pt_code = pt_code;temp_nb_data = nb_data;104365A–80C51–07/04114365A–80C51–07/04ea_save = EA;EA = 0;api_command = 0x0D;for (i=0 ; i< temp_nb_data; i++,add_pt_xram++,add_pt_code++){temp = *(unsigned char xdata *)add_pt_xram;FCON = 0x08;*(unsigned char xdata *)add_pt_code = temp;FCON = 0x00;}MAP_BOOT;__API_FLASH_ENTRY_POINT();UNMAP_BOOT;EA = ea_save; // restore interrupt statereturn(api_value);}#ifdef ONCHIP_EEPROM/*F************************************************************************ NAME: api_rd_eeprom*-------------------------------------------------------------------------* PARAMS:* unsigned char xdata *address : address to read* return:*-------------------------------------------------------------------------* PURPOSE:* This function allows to read a byte in Eeprom.*-------------------------------------------------------------------------* EXAMPLE:*-------------------------------------------------------------------------* NOTE:*-------------------------------------------------------------------------* REQUIREMENTS: The EEPROM mustn't be busy to perform the read access.* eeprom status :(EECON & 0x01)=1 busy, =0 free**************************************************************************/unsigned char __api_rd_eeprom_byte(unsigned char xdata *address){unsigned char val;bit ea_save;ea_save = EA;EA = 0;EECON = 0x02;val = *address;EECON = 0x00;EA = ea_save;return (val);}/*F************************************************************************ NAME: api_wr_eeprom_byte*-------------------------------------------------------------------------* PARAMS:* unsigned char xdata* address : address to read* unsigned char value : data to write* return:*-------------------------------------------------------------------------* PURPOSE:* This function allows to program a byte in Eeprom.*-------------------------------------------------------------------------* EXAMPLE:*-------------------------------------------------------------------------* NOTE:*-------------------------------------------------------------------------* REQUIREMENTS: The EEPROM mustn't be busy to perform the read access.* eeprom status :(EECON & 0x01)=1 busy, =0 free**************************************************************************/unsigned char __api_wr_eeprom_byte (unsigned char xdata *address,unsigned char value){bit ea_save;while(EECON & 0x01);// wait bit busyea_save = EA;EA = 0;EECON = 0x02;*address = value;/* addr is a pointer to external data mem */EECON = 0x50;EECON = 0xA0;EA = ea_save;return (1);}#endif124365A–80C51–07/04134365A–80C51–07/044. Example4.1 test_api.c/*C*********************************************************************** NAME: test_api.c*------------------------------------------------------------------------* Copyright (c) 2004 Atmel.*------------------------------------------------------------------------* RELEASE:* REVISION: 1.0*------------------------------------------------------------------------* PURPOSE: usage example of flash_eeprom_api.c*************************************************************************//*_____ I N C L U D E S ________________________________________________*/#include "flash_eeprom_api.c"/*F************************************************************************ NAME: main*-------------------------------------------------------------------------* PARAMS:*-------------------------------------------------------------------------* PURPOSE: usage example of flash_eeprom_api.c*-------------------------------------------------------------------------* EXAMPLE:*-------------------------------------------------------------------------* NOTE:*-------------------------------------------------------------------------* REQUIREMENTS:*************************************************************************/void main (void){int adress;char i=0;char data_tmp;/* write code page example */for(adress=0x0000;adress<0x007F;adress++){/* write 0x55 between 0x0000 and 0x007F of xram */*((unsigned char xdata*) adress)=0x55;}/* copy xram page to flash at 0x1100 */__api_wr_code_page(0x1100,0x0000,0x7F);/* write code byte example */i=0;for(adress=0x1000;adress<0x1006;adress++){/* write "ABCDEF" at 0x1000 */__api_wr_code_byte(adress,0x41+i++);}/* read and write code byte example */for(adress=0x1000;adress<0x1006;adress++){/* copy 0x1000-0x1006 to 0x1010-0x1016 in flash memory */data_tmp = __api_rd_code_byte(adress);__api_wr_code_byte(adress+0x0010,data_tmp);}#ifdef ONCHIP_EEPROM/* write eeprom byte example */i=0;for (adress=0x000;adress<0x400;adress++) /* write 1Ko of eeprom */{/* write a byte, write time = 10ms to 20ms */__api_wr_eeprom_byte(adress,i++);}/* read eeprom byte example */for (adress=0x000;adress<0x400;adress++){/* copy previous writed data from eeprom to flash at 0x1200 */data_tmp=__api_rd_eeprom_byte(adress);__api_wr_code_byte(0x1200+adress,data_tmp);}#endifwhile(1); /* endless */}144365A–80C51–07/04154365A–80C51–07/044.2 SFR Register Definition/*H**************************************************************************** NAME: AT89C51XD2.h*----------------------------------------------------------------------------* PURPOSE: SFR Description file for AT89C51xD2 products* ON KEIL compiler*****************************************************************************/#define Sfr(x, y) sfr x = y#define Sbit(x, y, z) sbit x = y^z#define Sfr16(x,y) sfr16 x = y/*----------------------------------------*//* Include file for 8051 SFR Definitions *//*----------------------------------------*//* BYTE Register */Sfr (P0 , 0x80);Sbit (P0_7 , 0x80, 7);Sbit (P0_6 , 0x80, 6);Sbit (P0_5 , 0x80, 5);Sbit (P0_4 , 0x80, 4);Sbit (P0_3 , 0x80, 3);Sbit (P0_2 , 0x80, 2);Sbit (P0_1 , 0x80, 1);Sbit (P0_0 , 0x80, 0);Sfr (P1 , 0x90);Sbit (P1_7 , 0x90, 7);Sbit (P1_6 , 0x90, 6);Sbit (P1_5 , 0x90, 5);Sbit (P1_4 , 0x90, 4);Sbit (P1_3 , 0x90, 3);Sbit (P1_2 , 0x90, 2);Sbit (P1_1 , 0x90, 1);Sbit (P1_0 , 0x90, 0);Sfr (P2 , 0xA0);Sbit (P2_7 , 0xA0, 7);Sbit (P2_6 , 0xA0, 6);Sbit (P2_5 , 0xA0, 5);Sbit (P2_4 , 0xA0, 4);Sbit (P2_3 , 0xA0, 3);Sbit (P2_1 , 0xA0, 1);Sbit (P2_0 , 0xA0, 0);Sfr (P3 , 0xB0);Sbit (P3_7 , 0xB0, 7);Sbit (P3_6 , 0xB0, 6);Sbit (P3_5 , 0xB0, 5);Sbit (P3_4 , 0xB0, 4);Sbit (P3_3 , 0xB0, 3);Sbit (P3_2 , 0xB0, 2);Sbit (P3_1 , 0xB0, 1);Sbit (P3_0 , 0xB0, 0);Sbit (RD , 0xB0, 7);Sbit (WR , 0xB0, 6);Sbit (T1 , 0xB0, 5);Sbit (T0 , 0xB0, 4);Sbit (INT1 , 0xB0, 3);Sbit (INT0 , 0xB0, 2);Sbit (TXD , 0xB0, 1);Sbit (RXD , 0xB0, 0);Sfr (P4 , 0xC0);Sbit (P4_7 , 0xC0, 7);Sbit (P4_6 , 0xC0, 6);Sbit (P4_5 , 0xC0, 5);Sbit (P4_4 , 0xC0, 4);Sbit (P4_3 , 0xC0, 3);Sbit (P4_2 , 0xC0, 2);Sbit (P4_1 , 0xC0, 1);Sbit (P4_0 , 0xC0, 0);Sfr (P5 , 0xE8);Sbit (P5_7 , 0xE8, 7);Sbit (P5_6 , 0xE8, 6);Sbit (P5_5 , 0xE8, 5);Sbit (P5_4 , 0xE8, 4);Sbit (P5_3 , 0xE8, 3);Sbit (P5_2 , 0xE8, 2);Sbit (P5_1 , 0xE8, 1);Sbit (P5_0 , 0xE8, 0);Sfr (PSW , 0xD0);Sbit (CY , 0xD0 , 7);Sbit (AC , 0xD0 , 6);164365A–80C51–07/04174365A–80C51–07/04Sbit (RS1 , 0xD0 , 4);Sbit (RS0 , 0xD0 , 3);Sbit (OV , 0xD0 , 2);Sbit (UD , 0xD0 , 1);Sbit (P , 0xD0 , 0);Sfr (ACC , 0xE0);Sfr (B , 0xF0);Sfr (SP , 0x81);Sfr (DPL , 0x82);Sfr (DPH , 0x83);Sfr (PCON , 0x87);Sfr (CKCON0 , 0x8F);Sfr (CKCON1 , 0xAF);/*------------------ TIMERS registers ---------------------*/Sfr (TCON , 0x88);Sbit (TF1 , 0x88, 7);Sbit (TR1 , 0x88, 6);Sbit (TF0 , 0x88, 5);Sbit (TR0 , 0x88, 4);Sbit (IE1 , 0x88, 3);Sbit (IT1 , 0x88, 2);Sbit (IE0 , 0x88, 1);Sbit (IT0 , 0x88, 0);Sfr (TMOD , 0x89);Sfr (T2CON , 0xC8);Sbit (TF2 , 0xC8, 7);Sbit (EXF2 , 0xC8, 6);Sbit (RCLK , 0xC8, 5);Sbit (TCLK , 0xC8, 4);Sbit (EXEN2 , 0xC8, 3);Sbit (TR2 , 0xC8, 2);Sbit (C_T2 , 0xC8, 1);Sbit (CP_RL2, 0xC8, 0);Sfr (T2MOD , 0xC9);Sfr (TL0 , 0x8A);Sfr (TL1 , 0x8B);Sfr (TL2 , 0xCC);Sfr (TH0 , 0x8C);Sfr (TH1 , 0x8D);Sfr (TH2 , 0xCD);Sfr (RCAP2L , 0xCA);Sfr (RCAP2H , 0xCB);Sfr (WDTRST , 0xA6);/*------------------- UART registers ------------------------*/Sfr (SCON , 0x98);Sbit (SM0 , 0x98, 7);Sbit (FE , 0x98, 7);Sbit (SM1 , 0x98, 6);Sbit (SM2 , 0x98, 5);Sbit (REN , 0x98, 4);Sbit (TB8 , 0x98, 3);Sbit (RB8 , 0x98, 2);Sbit (TI , 0x98, 1);Sbit (RI , 0x98, 0);Sfr (SBUF , 0x99);Sfr (SADEN , 0xB9);Sfr (SADDR , 0xA9);/*-------------------- Internal Baud Rate Generator --------*/Sfr (BRL , 0x9A);Sfr (BDRCON , 0x9B);/*-------------------- IT registers -----------------------*/Sfr (IEN0 , 0xA8);Sfr (IEN1 , 0xB1);Sfr (IPH0 , 0xB7);Sfr (IPH1 , 0xB3);Sfr (IPL0 , 0xB8);Sfr (IPL1 , 0xB2);/* IEN0 */Sbit (EA , 0xA8, 7);Sbit (EC , 0xA8, 6);Sbit (ET2 , 0xA8, 5);Sbit (ES , 0xA8, 4);Sbit (ET1 , 0xA8, 3);Sbit (EX1 , 0xA8, 2);Sbit (ET0 , 0xA8, 1);Sbit (EX0 , 0xA8, 0);/*--------------------- PCA registers -----------------------------*/Sfr (CCON , 0xD8);Sfr (CMOD , 0xD9);Sfr (CH , 0xF9);184365A–80C51–07/04194365A–80C51–07/04Sfr (CCAP0H , 0xFA);Sfr (CCAP0L , 0xEA);Sfr (CCAPM0 , 0xDA);Sfr (CCAP1H , 0xFB);Sfr (CCAP1L , 0xEB);Sfr (CCAPM1 , 0xDB);Sfr (CCAP2H , 0xFC);Sfr (CCAP2L , 0xEC);Sfr (CCAPM2 , 0xDC);Sfr (CCAP3H , 0xFD);Sfr (CCAP3L , 0xED);Sfr (CCAPM3 , 0xDD);Sfr (CCAP4H , 0xFE);Sfr (CCAP4L , 0xEE);Sfr (CCAPM4 , 0xDE);/* CCON */Sbit (CF , 0xD8, 7);Sbit (CR , 0xD8, 6);Sbit (CCF4 , 0xD8, 4);Sbit (CCF3 , 0xD8, 3);Sbit (CCF2 , 0xD8, 2);Sbit (CCF1 , 0xD8, 1);Sbit (CCF0 , 0xD8, 0);/*------------------ T W I registers ------------------------------*/Sfr ( SSCON , 0x93);Sfr ( SSCS , 0x94);Sfr ( SSDAT , 0x95);Sfr ( SSADR , 0x96);Sfr ( PI2, 0xF8);Sbit (PI2_1 , 0xF8, 1);Sbit (PI2_0 , 0xF8, 0);/*-------------------- OSC control registers ----------------------*/Sfr ( CKSEL , 0x85 );Sfr ( OSCCON , 0x86 );Sfr ( CKRL , 0x97 );/*-------------------- Keyboard control registers -----------------*/Sfr ( KBLS , 0x9C );Sfr ( KBE , 0x9D );Sfr ( KBF , 0x9E );/*-------------------- SPI ---------------------- -----------------*/Sfr ( SPCON, 0xC3 );Sfr ( SPSTA, 0xC4 );Sfr ( SPDAT, 0xC5 );/*------ Misc ----------------------------------------------------*/Sfr( AUXR , 0x8E);Sfr ( AUXR1, 0xA2);Sfr ( FCON, 0xD1);/*------ E data --------------------------------------------------*/Sfr ( EECON, 0xD2 );204365A–80C51–07/04Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company’s standard warranty which is detailed in Atmel’s Terms and Conditions located on the Company’s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel’s products are not authorized for use as critical components in life support devices or systems.Atmel CorporationAtmel Operations2325 Orchard Parkway San Jose, CA 95131Tel: 1(408) 441-0311Fax: 1(408) 487-2600Regional HeadquartersEuropeAtmel SarlRoute des Arsenaux 41Case Postale 80CH-1705 Fribourg SwitzerlandTel: (41) 26-426-5555Fax: (41) 26-426-5500AsiaRoom 1219Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong KongTel: (852) 2721-9778Fax: (852) 2722-1369Japan9F, Tonetsu Shinkawa Bldg.1-24-8 ShinkawaChuo-ku, Tokyo 104-0033JapanTel: (81) 3-3523-3551Fax: (81) 3-3523-7581Memory2325 Orchard Parkway San Jose, CA 95131Tel: 1(408) 441-0311Fax: 1(408) 436-4314Microcontrollers2325 Orchard Parkway San Jose, CA 95131Tel: 1(408) 441-0311Fax: 1(408) 436-4314La Chantrerie BP 7060244306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18Fax: (33) 2-40-18-19-60ASIC/ASSP/Smart CardsZone Industrielle13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00Fax: (33) 4-42-53-60-011150 East Cheyenne Mtn. Blvd.Colorado Springs, CO 80906Tel: 1(719) 576-3300Fax: 1(719) 540-1759Scottish Enterprise Technology Park Maxwell BuildingEast Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000Fax: (44) 1355-242-743RF/AutomotiveTheresienstrasse 2Postfach 353574025 Heilbronn, Germany Tel: (49) 71-31-67-0Fax: (49) 71-31-67-23401150 East Cheyenne Mtn. Blvd.Colorado Springs, CO 80906Tel: 1(719) 576-3300Fax: 1(719) 540-1759Biometrics/Imaging/Hi-Rel MPU/High Speed Converters/RF DatacomAvenue de Rochepleine BP 12338521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00Fax: (33) 4-76-58-34-80e-mail********************Web Site4365A–80C51–07/04/xM©Atmel Corporation 2004. All rights reserved. Atmel, the Atmel logo, andcombinations thereof are registered trademarks of Atmel Corporation or its subsidiaries. Windows ® Windows 98™, Windows XP ™, and Windows 2000™ are trademarks and/ore registered trademark of Microsoft Corporation. Other terms and product names in this document may be the trademarks of others.。
笙泉 8051 烧录器中文使用手册

10
3.3.2 将编程器连接起来
10
3.3.3 按编程器里的‘Auto’键,开始编程
10
4. 芯片储存空间的配置
11
4.1 MPC87L/E51/52
11
5. 芯片的硬件选项
12
5.1 MPC87L/E51/52
12
-2-
MEGAWIN
MAKE YOU WIN
笙泉 8051 编程器使用手册
V1.10
MEGAWIN
MAKE YOU WIN
笙泉 8051 编程器使用手册
V1.10
3.1.4 设置硬件选项 在这设置一一些硬件选项 1): ISP 空间设置. 如需要使用到 ISP 代码,则必须设置相对应的空间大小来存储 ISP 代码 2): OSC 设置. 如需使用内部 ROSC, 则必须 OSC 频率,并且选上 ENRCO
用于存放客户代码和数据,这部分数据可由编程器和 ISP 程序进行擦除和读写操作等编程操作 IAP 空间:
是一段非易失性的数据存储空间,这部分数据可由编程器、ISP 程序以及 AP 程序进行擦除和读写操作等 编程操作 ISP 空间: 是一段特殊的存储空间,可独立运行程序代码,一般是用于对 AP 和 IAP 空间进行在线编程,而 ISP 本 身的存储空间只能用编程器来进行编程 笙泉的 8051 芯片的存储空间的配置情况会各有差异
笙泉 8051 编程器使用手册
V1.10
日期 2008/10/22 2008/11/24
- 13 -
按 AUTO 键开始编程. 在编程过程中 “黄灯”亮, 完成后,如果成功则”绿灯”亮,且蜂鸣器长鸣一声, 否则”红灯” 亮,且蜂鸣器短鸣 10 声.
- 10 -
8051_芯片手册

8051芯片手册目录1 NL06F86 芯片概述 (1)1.1结构框图 (1)1.2NL06F86 性能 (1)1.3外设连接示意图 (4)1.4管脚定义 (5)1.5NL06F86 最小系统 (18)1.6部分管脚的配臵电路 (18)2 内存映射 (20)3 CPU内核 (23)3.1概述 (23)3.2CPU编程模型 (24)3.3处理器寻址方式 (28)3.4CPU指令集 (32)3.5MMU和Cache (48)4 外设功能 (61)4.1 功能综述 (61)4.2 所有寄存器列表 (62)4.3 外设使用说明 (71)4.4 编程实例 (71)5 程序起动描述 (73)6 存储器控制器 (74)6.2 寄存器表 (74)6.3 寄存器功能描述 (74)6.4 模块管脚描述 (76)6.5 典型电路 (80)6.6 编程实例 (81)7 中断控制器 (83)7.1 功能综述 (83)7.2 寄存器表 (84)7.3 寄存器功能描述 (84)7.4 编程实例 (86)8 定时器 (88)8.1 功能综述 (88)8.2 寄存器表 (88)8.3 寄存器功能描述 (89)8.4 编程实例 (90)9 通用I/O (91)9.1 功能综述 (91)9.2 寄存器表 (91)9.3 寄存器功能描述 (93)9.4 编程实例 (96)10 HW控制器 (98)10.1 功能综述 (98)10.2 寄存器表 (98)10.4 编程实例 (99)11 以太网MAC控制器 (100)11.1 功能综述 (100)11.2 寄存器表 (100)11.3 寄存器功能描述 (101)11.4 模块管脚描述 (106)11.5 典型电路 (107)11.6 编程实例 (107)12 通用异步收发器UARTs (112)12.1 功能综述 (112)12.2 UART寄存器表 (112)12.3 寄存器功能描述 (113)12.4 模块管脚描述 (117)12.5 编程实例 (118)13 I2C总线接口 (122)13.1 功能综述 (122)13.2 寄存器表 (122)13.3 寄存器功能描述 (122)13.4 时序波形图 (123)13.5 模块管脚描述 (125)13.6 典型电路 (125)13.7 编程实例 (126)14 低速外设接口 (128)14.2 寄存器表 (128)14.3 寄存器功能描述 (128)14.4 模块管脚描述 (130)14.5 典型电路 (131)14.6 编程实例 (132)15 显示接口 (134)15.1 功能总述 (134)15.2 寄存器表 (134)15.3 寄存器功能描述 (136)15.4 模块管脚描述 (143)15.5 典型电路 (144)15.6 编程实例 (145)16 磁卡接口 (149)16.1 功能综述 (149)16.2 寄存器表 (149)16.3 寄存器功能描述 (149)16.4 模块管脚描述 (151)16.5 编程实例 (151)17 IC卡接口 (153)17.1 功能综述 (153)17.2 寄存器表 (153)17.3 寄存器功能描述 (154)17.4 模块管脚描述 (156)17.6 编程实例 (157)18 打印机接口 (159)18.1 功能综述 (159)18.2 寄存器表 (159)18.3 寄存器功能描述 (159)18.4 模块管脚描述 (161)18.5 典型电路 (162)18.6 编程实例 (162)19 PC键盘接口 (164)19.1 功能综述 (164)19.2 寄存器表 (164)19.3 寄存器功能描述 (164)19.4 模块管脚描述 (165)19.5 数据格式和时序图 (166)19.6 典型电路 (166)19.7 编程实例 (167)20 PWM接口 (169)20.1 功能综述 (169)20.2 寄存器表 (169)20.3 寄存器功能描述 (170)20.4 模块管脚描述 (171)20.5 典型电路 (171)20.6 编程实例 (172)21 蜂鸣器 (173)21.1 功能综述 (173)21.2 寄存器表 (173)21.3 寄存器功能描述 (173)21.4 模块管脚描述 (174)21.5 典型电路 (174)21.6 编程实例 (175)22 DES控制器 (176)22.1 功能综述 (176)22.2 寄存器表 (176)22.3 寄存器功能描述 (176)22.4 编程实例 (177)23 封装尺寸 (179)1. 8051 芯片概述8051微控制器属于MCS-51系列,自其1980年由Inter公司设计以来,由于其完善的指令集,在嵌入式系统应用中占有很大的市场。
MC51F8124 用户手册说明书

MC51F8124晟矽微电本公司保留对以下所有产品在可靠性、功能和设计方面的改进作进一步说明的权利。
MC51F8124 用户手册 V1.7 8位增强型8051单片机主要特性CORE✧ 1T 高速增强型8051内核 ✧ 双DPTR ROM✧ 片上16K 字节 FLASH ,擦写10万次以上✧ 片上1024字节 E2(EEPROM),擦写10万次以上 ✧ 支持代码分区保护功能(有效防止非法读/写/擦) ✧ 支持FLASH 和E2在电路编程(ICP ), 支持E2在应用编程(IAP ) RAM✧ 片上1536(256+1280)字节 SRAM 时钟源✧ 片上高精度32MHz 高速振荡器(常温5.0V 电压下±1%精度;全工作条件下±5%精度)✧ 片上32KHz 超低功耗低速振荡器,供看门狗定时器和T3使用✧ 外部可选接32768Hz 晶体振荡器 电源管理模式✧ 4种工作模式:高速/低速/停止/休眠✧ 增加高级能耗控制功能,满足用户低功耗的需求 复位✧ 上电复位(POR )/外部复位/低电压复位(LVR )/看门狗复位/软件复位✧ LVR 电压4级可选:2.1V 、2.5V 、3.5V 、4.1V ✧ 看门狗复位可选8种溢出时间 I/O✧ 最多26个双向通用I/O 口(28PIN 封装下) ✧ 支持3种输入/输出模式,支持输入上拉电阻配置 ✧ 14个IO 具备独立大电流驱动能力✧ 24个I/O 可软件模拟成1/2 BIAS 的LCD COM 口 定时器/计数器✧ 2个16位T0/T1定时器,兼容标准8051✧ 1个16位增强型T2定时器,兼容8052的T2,带输入捕获和输出比较功能 ✧ 1个16位T3时基定时器,可连接外部32768Hz 晶振,在停止/休眠模式下可定时唤醒 PWM 定时器✧ 1路独立8位PWM0,可作通用定时器✧ 3组共6路16位PWM1阵列,可互补输出且死区时间可调,并具有故障保护中断功能✧ PWM1可在选片上高速时钟或其分频下独立工作 12位高精度ADC✧ 12位高精度逐次逼近型ADC✧ 14通道:外部12通道+内部2通道✧ 参考电压可选:内部2.0V 、VDD 、Vref 引脚输入 2路UART✧ 2路UART 模块,可兼容8051标准✧ 增强UART0支持“帧出错”检测及自动地址识别 ✧ 支持8位同步半双工、8位/9位异步全双工等4种工作方式 SPI✧ 支持全双工,3线/4线同步模式,主/从机可选 ✧ 支持主机模式错误用以防止主机冲突 TK 触摸按键✧ 最大支持16通道的高灵敏触摸按键✧ 支持4MHz/2MHz/1MHz/500KHz 四种工作频率 ✧ 支持可选基准电压,支持触摸按键扫描中断,支持触摸按键唤醒 中断✧ INT0X 、T0、INT1X 、T1、UART0、TK 、ADC 、T2、SPI 、PWM1、PWM0、PWM1FB 、UART1、CRC 、T3共15个中断源 ✧ 2级中断优先级可设 ✧ 其中INTnx (n=0~1,x=0~4)支持多重映射输入,5选1分别对应两个中断源(INT0x/INT1x );支持上升沿触发方式和高电平脉宽测量功能 循环冗余校验算法模块(符合CRC-16标准) 双两线调试与编程接口✧ 两组调试和编程接口任意二选一,支持自动识别 开发工具兼容KEIL TM 集成开发环境 工作电压✧ 2.0V ~5.5V 工作环境温度 ✧ -40℃~85℃ 封装形式 ✧ SOP28、SSOP28、SOP24、SSOP24、SOP20、TSSOP201T 8051内核FLASH 型MCU ,16KB FLASH ROM ,1536B SRAM ,1KB 独立EEPROM ,12位高速ADC ,16通道高灵敏触摸电路,6通道16位PWM ,8位PWM ,4个16位定时器,2路UART ,SPI ,CRC ,双两线调试1产品简介1.1概述本产品是一款高速低功耗1T周期8051内核8位增强型FLASH微控制器芯片,较传统8051相比,运行效率更高。
硅科 C8051F32x 开发套件用户手册说明书

Rev. 0.9 2/14Copyright © 2014 by Silicon LaboratoriesC8051F32xX EVELOPMENT IT SER S UIDE1. Kit ContentsThe C8051F32x Development Kit contains the following items:•C8051F320 Target Board•C8051Fxxx Development Kit Quick-Start Guide •AC to DC Power Adapter•USB Debug Adapter (USB to Debug Interface)•USB Cable •CD-ROM2. Hardware Setup Using a USB Debug AdapterThe target board is connected to a PC running the Silicon Laboratories IDE via the USB Debug Adapter as shown in Figure 1.1.Connect the USB Debug Adapter to the DEBUG connector on the target board with the 10-pin ribbon cable.2.Connect one end of the USB cable to the USB connector on the USB Debug Adapter.3.Connect the other end of the USB cable to a USB Port on the PC.4.Connect the ac/dc power adapter to power jack P1 on the target board.Notes:•Use the Reset button in the IDE to reset the target when connected using a USB Debug Adapter.•Remove power from the target board and the USB Debug Adapter before connecting or disconnecting the ribbon cable from the target board. Connecting or disconnecting the cable when the devices have power can damage the device and/or the USB Debug Adapter.Figure 1.Hardware Setup Using a USB Debug AdapterNote:The C8051F320 target board has the ability to be powered through the USB cable. To enable the USB-powered mode,move the shorting block located at header J2 to header J11.PWRP1.6C8051F32x3. Software SetupSimplicity Studio greatly reduces development time and complexity with Silicon Labs EFM32 and 8051 MCU products by providing a high-powered IDE, tools for hardware configuration, and links to helpful resources, all in one place.Once Simplicity Studio is installed, the application itself can be used to install additional software and documentation components to aid in the development and evaluation process.Figure2.Simplicity StudioThe following Simplicity Studio components are required for the C8051F320 Development Kit:⏹ 8051 Products Part Support ⏹ Simplicity Developer PlatformDownload and install Simplicity Studio from /8bit-software or /simplicity-studio .Once installed, run Simplicity Studio by selecting Start →Silicon Labs →Simplicity Studio →Simplicity Studio from the start menu or clicking the Simplicity Studio shortcut on the desktop. Follow the instructions to install the software and click Simplicity IDE to launch the IDE.The first time the project creation wizard runs, the Setup Environment wizard will guide the user through the process of configuring the build tools and SDK selection.In the Part Selection step of the wizard, select from the list of installed parts only the parts to use during development. Choosing parts and families in this step affects the displayed or filtered parts in the later device selection menus. Choose the C8051F32x family by checking the C8051F32x check box. Modify the part selection at any time by accessing the Part Management dialog from the Window →Preferences →Simplicity Studio →Part Management menu item.Simplicity Studio can detect if certain toolchains are not activated. If the Licensing Helper is displayed after completing the Setup Environment wizard, follow the instructions to activate the toolchain.C8051F32x3.1. Running BlinkyEach project has its own source files, target configuration, SDK configuration, and build configurations such as the Debug and Release build configurations. The IDE can be used to manage multiple projects in a collection called a workspace. Workspace settings are applied globally to all projects within the workspace. This can include settings such as key bindings, window preferences, and code style and formatting options. Project actions, such as build and debug are context sensitive. For example, the user must select a project in the Project Explorer view in order to build that project.To create a project based on the Blinky example:1. Click the Simplicity IDE tile from the Simplicity Studio home screen.2. Click the Create new project link from the welcome screen or go to File →New →Silicon Labs MCU Project .3. In the Kit drop-down, select C8051F320 Development Kit , in the Part drop-down, select C8051F320, and in the SDK drop-down, select the desired SDK. Click Next .4. Select Example and click Next .5. Under C8051F320 Development Kit in the Blinky folder, select F320-1 Blinky and click Finish .6. Click on the project in the Project Explorer and click Build , the hammer icon in the top bar. Alternatively, go to Project →Build Project .7. Click Debug to download the project to the hardware and start a debug session.8. Press the Resumebutton to start the code running. The LED should blink.9. Press the Suspend button to stop the code.10. Press the Reset the devicebutton to reset the target MCU.11. Press the Disconnectbutton to return to the development perspective.3.2. Simplicity Studio HelpSimplicity Studio includes detailed help information and device documentation within the tool. The help containsdescriptions for each dialog window. To view the documentation for a dialog, click the question mark icon in the window:This will open a pane specific to the dialog with additional details.The documentation within the tool can also be viewed by going to Help →Help Contents or Help →Search .C8051F32x3.3. Legacy 8-bit IDENote:Using the Simplicity Studio tools with the C8051F320 Development Kit is recommended. See section 3. "SoftwareSetup‚" on page 2 for more information.Download the 8-bit software from the website (/8bit-software ) or use the provided installer on the CD-ROM to install the software tools for the C8051F32x devices. After installation, examples can be found in ...\Examples\C8051F320_1 in the installation directory. At a minimum, the C8051F320 DK requires:⏹ Silicon Labs IDE —Software enabling initial evaluation, development, and debugging.⏹ Configuration Wizard 2—Initialization code generation software for the C8051F32x devices.⏹ Keil C51 Tools —Keil 8051 Compiler/Assembler/Linker toolchain.Other software available includes:⏹ Keil µVision Driver —Driver for the Keil µVision IDE that enables development and debugging onC8051Fxxx MCUs.⏹ Flash Programming Utilities and MCU Production Programmer —Programming utilities for the production line. More information on the available programming options can be found on the website:/products/mcu/Pages/ProgrammingOptions.aspx .⏹ ToolStick Development Tools —Software and examples for the ToolStick development platform. More information on this platform can be found at /toolstick .The development kit includes the latest version of the C51 Keil 8051 toolset. This toolset is initially limited to a code size of 2kB and programs start at code address 0x0800. After registration, the code size limit is removed entirely and programs will start at code address 0x0000.To register the Keil toolset:1. Find the Product Serial Number printed on the CD-ROM. If you no longer have this serial number, register on the Silicon Labs website (/8bit-software ) to obtain the serial number.2. Open the Keil µVision4 IDE from the installation directory with administrative privileges.3. Select FileLicense Management to open the License Management window.Figure 3.Keil µVision4 IDE License Management Window4. Click on the Get LIC via Internet... button to open the Obtaining a License IDE Code (LIC) window.5. Press OK to open a browser window to the Keil website. If the window doesn’t open, navigate to /license/install.htm .6. Enter the Silicon Labs Product Serial Number printed on the CD-ROM, along with any additional requiredC8051F32xinformation.7. Once the form is complete, click the Submit button. An email will be sent to the provided email addresswith the license activation code.8. Copy the License ID Code (LIC) from the email.9. Paste the LIC into the New License ID Code (LIC) text box at the bottom of the License Managementwindow in µVision4.10. Press the Add LIC button. The window should now list the PK51 Prof. Developers Kit for Silabs as alicensed product.11. Click the Close button.C8051F32x4. Target BoardThe C8051F32x Development Kit includes a target board with a C8051F320 device pre-installed for evaluation and preliminary software development. Numerous input/output (I/O) connections are provided to facilitate prototyping using the target board. Refer to Figure4 for the locations of the various I/O connectors.P1Power connector (accepts input from 7 to 15 VDC unregulated power adapter)J1 36-pin Expansion I/O connectorJ2Power Target Board from power adapterJ3Port I/O Configuration ConnectorJ4DEBUG connector for Debug Adapter interfaceJ5 DB-9 connector for UART0 RS232 interfaceJ6 Analog I/O terminal blockJ7Low pass filter connectorJ8USB Debug Adapter target board power connectorJ9, J10 External crystal enable connectorsJ11Power Target Board from USBJ12Connects external capacitance to P0.7J13 Connects R14 Potentiometer to P1.7J14USB connector for USB interfaceFigure4.C8051F320 Target BoardC8051F32x4.1. System Clock SourcesThe C8051F320 device installed on the target board features a calibrated programmable internal oscillator which is enabled as the system clock source on reset. After reset, the internal oscillator operates at a frequency of 1.5MHz (±1.5%) by default but may be configured by software to operate at other frequencies. Therefore, in many applications an external oscillator is not required. However, if you wish to operate the C8051F320 device at a frequency not available with the internal oscillator, an external crystal may be used. Refer to the C8051F32x data sheet for more information on configuring the system clock source.The target board is designed to facilitate the installation of an external crystal. Remove shorting blocks at headers J9 and J10 and install the crystal at the pads marked Y1. Install a 10MΩ resistor at R9 and install capacitors at C14 and C15 using values appropriate for the crystal you select. Refer to the C8051F32x data sheet for more information on the use of external oscillators.4.2. Switches and LEDsThree switches are provided on the target board. Switch SW1 is connected to the RESET pin of the C8051F320. Pressing SW1 puts the device into its hardware-reset state. Switch SW2 and SW3 are connected to the C8051F320’s general purpose I/O (GPIO) pins through headers. Pressing SW2 or SW3 generates a logic low signal on the port pin. Remove the shorting blocks from the header to disconnect SW2 and SW3 from the port pins. The port pin signals are also routed to pins on the J1 I/O connector. See Table1 for the port pins and headers corresponding to each switch.Three LEDs are also provided on the target board. The red LED labeled PWR is used to indicate a power connection to the target board. The green LEDs labeled with port pin names are connected to the C8051F320’s GPIO pins through headers. Remove the shorting blocks from the header to disconnect the LEDs from the port pin. The port pin signals are also routed to pins on the J1 I/O connector. See Table1 for the port pins and headers corresponding to each LED.Also included on the C8051F320 target board is a 10KΩ Thumb-Wheel Rotary Potentiometer, part number R14. The Potentiometer is connected to the C8051F320’s GPIO pin through a header. Remove the shorting block from the header to disconnect the Potentiometer from the port pin. The port pin signal is also routed to a pin on the J1 I/ O connector. See Table1 for the port pin and header corresponding to the Potentiometer.Table 1. Target Board I/O DescriptionsDescription I/O HeaderSW1Reset noneSW2P2.0J3[1–2]SW3P2.1J3[3–4]Green LED P2.2J3[5–6]Green LED P2.3J3[7–8]Red LED PWR nonePotentiometer R14J13C8051F32x4.3. Universal Serial Bus (USB) Interface (J14)A Universal Serial Bus (USB) connector (J14) is provided to facilitate connections to the USB interface on the C8051F320. Table2 shows the J14 pin definitions.Table 2. USB Connector Pin DescriptionsPin #Description1VBUS2D-3D+4GND (Ground)4.4. Expansion I/O Connector (J1)The 32-pin Expansion I/O connector J1 provides access to all signal pins of the C8051F320 device. Pins for +3V, digital ground and the output of an on-board low-pass filter are also available. A small through-hole prototyping area is also provided. All I/O signals routed to connector J1 are also routed to through-hole connection points between J1 and the prototyping area (see Figure4 on page6). Each connection point is labeled indicating the signal available at the connection point. See Table3 for a list of pin descriptions for J1.Table 3. J1 Pin DescriptionsPin #Description Pin #Description Pin #Description1+3VD(+3.3VDC)13P1.225P2.62PWM Output14P1.326P2.73P0.015P1.427P3.04P0.116P1.528/RST (Reset)5P0.217P1.629VREGIN6P0.318P1.730VDD7P0.419P2.031VBUS8P0.520P2.132GND (Ground)9P0.621P2.210P0.722P2.311P1.023P2.412P1.124P2.54.5. USB Self-Powered Configuration (J2, J11)The C8051F320 target board can be configured as a self-powered USB device to take power from the USB cable instead of the ac/dc adapter connected at P1. To configure the target boards as a self-powered USB device, remove the shorting block from J2 and install on J11. (A shorting block should only be installed on J2 or J11, never both at the same time.) Install shorting blocks in the following manner:J2(ON) & J11(OFF) →Target Board is powered from the ac/dc Adapter at P1.J2(OFF) & J11(ON) →Target Board is powered from the USB connectionNote: When the C8051F320 target board is self-powered from the USB, the Serial Adapter is not powered from the target board. The Serial Adapter must be powered directly by connecting the ac/dc adapter to the Serial Adapters’dc power jack. Also, the RS232 Serial Interface (J5) cannot be used when powering the target board from the USB.C8051F32x4.6. Target Board DEBUG Interface (J4)The DEBUG connector (J4) provides access to the DEBUG (C2) pins of the C8051F320. It is used to connect the Serial Adapter or the USB Debug Adapter to the target board for in-circuit debugging and Flash programming. Table4 shows the DEBUG pin definitions.Table 4. DEBUG Connector Pin DescriptionsPin #Description1+3VD(+3.3VDC)2, 3, 9GND (Ground)4C2D5/RST(Reset)6P3.07C2CK8Not Connected10USB Power4.7. Serial Interface (J5)A RS232 transceiver circuit and DB-9 (J5) connector are provided on the target board to facilitate serial connections to UART0 of the C8051F320. The TX, RX, RTS and CTS signals of UART0 may be connected to the DB-9 connector and transceiver by installing shorting blocks on header J3.J3[9-10]- Install shorting block to connect UART0 TX (P0.4) to transceiver.J3[11-12]- Install shorting block to connect UART0 RX (P0.5) to transceiver.J3[13-14]- Install shorting block to connect UART0 RTS (P2.6) to transceiver.J3[15-16]- Install shorting block to connect UART0 CTS (P2.7) to transceiver.4.8. Analog I/O (J6)Several of the C8051F320 target device’s port pins are connected to the J6 terminal block. Refer to Table5 for the J6 terminal block connections.Table 5. J6 Terminal Block Pin DescriptionsPin #Description1P2.5 / AIN2.52P2.4 / AIN2.43GND (Ground)4P0.7 / Vref (Voltage Reference)4.9. USB Debug Adapter Target Board Power Connector (J8)The USB Debug Adapter includes a connection to provide power to the target board. This connection is routed from J4[10] to J8[1]. Place a shorting block at header J8[2-3] to power the board directly from an ac/dc power adapter. Place a shorting block at header J8[1-2] to power the board from the USB Debug Adapter. Please note that the second option is not supported with either the EC1 or EC2 Serial Adapters.4.10. Low-Pass Filter (J7)The C8051F320 target board features a low-pass filter that may be connected to port pin P2.4. Install a shorting block on J7[1-2] to connect the P2.4 pin of the target device to the low-pass filter input. The output of the low-pass filter is routed to the PWM signal at J1[2]. The C8051F320 may be programmed to generate a PWM (Pulse-Width Modulated) waveform which is then input to the low-pass filter to implement a user-controlled PWM digital-to-analog converter. Refer to Applications Note AN107 - Implementing 16-Bit PWM Using the PCA for a discussion on generating a programmable dc voltage level with a PWM waveform and low-pass filter.C8051F32xC8051F32x D OCUMENT C HANGE L ISTRevision 0.6 to Revision 0.7⏹ Section 1, added USB Debug Adapter and USB Cable.⏹ Section 2, changed name from "Hardware Setup" to "Hardware Setup using an EC2 Serial Adapter".⏹ Section 2, added 2 Notes bullets.⏹ Section 2, removed Note from bottom of page.⏹ Added Section 3, "Hardware Setup using a USB Debug Adapter".⏹ Section 5.4.2, changed step 2 to include new instructions.⏹ Section 7, J4, changed "Serial Adapter" to "Debug Adapter".⏹ Target Board DEBUG Interface Section, added USB Debug Adapter.⏹ DEBUG Connector Pin Descriptions Table, changed pin 4 to C2D.⏹ Changed "jumper" to "header".⏹ EC2 Serial Adapter section, added EC2 to the section title, table title and figure title.⏹ EC2 Serial Adapter section, changed "JTAG" to "DEBUG".⏹ Added "USB Debug Adapter" section.⏹ Section 7, J8, changed "Serial Adapter" to "USB Debug Adapter"⏹ DEBUG Connector Pin Descriptions Table, changed pin 10 to USB Power⏹ USB Debug Adapter Target Board Power Connector (J8) Section, changed "Serial" to "USB Debug" Revision 0.7 to Revision 0.8⏹ Removed EC2 Serial Adapter from Kit Contents.⏹ Removed Section 2. Hardware Setup using an EC2 Serial Adapter. See RS232 Serial Adapter (EC2)User's Guide.⏹ Removed Section 8. EC2 Serial Adapter. See RS232 Serial Adapter (EC2) User's Guide.⏹ Removed Section 9. USB Debug Adapter. See USB Debug Adapter User's Guide.Revision 0.8 to Revision 0.9⏹ Updated 3. "Software Setup‚" on page 2.DisclaimerSilicon Laboratories intends to provide customers with the latest, accurate, and in-depth documentation of all peripherals and modules available for system and software implementers using or intending to use the Silicon Laboratories products. Characterization data, available modules and peripherals, memory sizes and memory addresses refer to each specific device, and "Typical" parameters provided can and do vary in different applications. Application examples described herein are for illustrative purposes only. Silicon Laboratories reserves the right to make changes without further notice and limitation to product information, specifications, and descriptions herein, and does not give warranties as to the accuracy or completeness of the included information. Silicon Laboratories shall have no liability for the consequences of use of the information supplied herein. This document does not imply or express copyright licenses granted hereunder to design or fabricate any integrated circuits. The products must not be used within any Life Support System without the specific written consent of Silicon Laboratories. A "Life Support System" is any product or system intended to support or sustain life and/or health, which, if it fails, can be reasonably expected to result in significant personal injury or death. Silicon Laboratories products are generally not intended for military applications. Silicon Laboratories products shall under no circumstances be used in weapons of mass destruction including (but not limited to) nuclear, biological or chemical weapons, or missiles capable of delivering such weapons.Trademark InformationSilicon Laboratories Inc., Silicon Laboratories, Silicon Labs, SiLabs and the Silicon Labs logo, CMEMS®, EFM, EFM32, EFR, Energy Micro, Energy Micro logo and combinations thereof, "the world’s most energy friendly microcontrollers", Ember®, EZLink®, EZMac®, EZRadio®, EZRadioPRO®, DSPLL®, ISOmodem ®, Precision32®, ProSLIC®, SiPHY®, USBXpress® and others are trademarks or registered trademarks of Silicon Laboratories Inc. ARM, CORTEX, Cortex-M3 and THUMB are trademarks or registered trademarks of ARM Holdings. Keil is a registered trademark of ARM Limited. All other products or brand names mentioned herein are trademarks of their respective holders. Silicon Laboratories Inc.400 West Cesar ChavezAustin, TX 78701USAIoT Portfolio/IoT SW/HW /simplicity Quality /quality Support and Community 。
C8051F开发板用户手册

2
亿和电子工作室出品
C8051F-DK
目录 1. 背景简述......................................................................................................................................5 1.1. 亿和 C8051F 实验仪简介................................................................................................5 1.2. C8051F 单片机的优势..................................................................................................... 5 1.3. 实验仪用途...................................................................................................................... 6 2. 准备工作..................................................................................................................................... 6 2.1. 相关软件介绍........................................................................................................
新华龙单片机C8051F410学习板使用手册

目录一、学习板概括 (1)二、准备工作 (1)三、学习板硬件介绍 (3)四、实验程序 (5)实验一、跑马灯 (5)实验二、独立按键 (6)实验三、继电器控制 (7)实验四、P2口驱动数码管 (8)实验五、定时器 (10)实验六、99S倒计时 (10)实验七、TM1668 (11)实验八、AD采样模数转换+TM1668 (17)实验九、串口通信 (18)实验十、ADC+UART (19)实验十一、1602液晶显示 (19)实验十二、8Bit PWM输出 (21)实验十三、单线温度传感器18B20 (21)一、学习板概括:本手册适用于江南晶创科技推出的C8051F410单片机学习板、开发板第二版(V2.0)。
C8051F410单片机学习板由江南科技创办人朱发旺、陈家乐及其团队设计,版权归其所有!淘宝旗舰店(直销店),QQ交流群:112481187。
该学习板主控制芯片使用了新华龙(Silicon)单片机c8051f410。
配套JTAG 仿真器编程器U-EC5,该仿真器可以对C8051F大部分系列单片机进行仿真、调试、单步、烧录、下载、加密等操作。
学习板采用模块化设计,尽量做到各功能模块完全独立,互不干扰,减小初学者编程误区。
使是初学者可快速了解主板硬件电路的结构,尽快熟悉硬件电路,快速入门。
此外由于各模块可独立工作,所有引脚均已使用标准接口外扩,所以可以将模块用于其他场合,大大增加开发板的用途!二、准备工作:1、软件安装(1)本学习板配套的所有演示程序均使用C语言编辑,编写软件为Keil 51(Uvision4),推荐大家也是用此软件编程;(2)程序下载(烧写)软件使用的是U-EC5中文下载程序;(3)JTAG U-EC5 驱动程序,部分电脑系统可自动安装;注:以上软件均支持windows Xp/win7 32/64,JTAG仿真器支持USB2.0。
2、硬件连接使用C8051F410单片机学习板,需要USB MiNi接口数据线一根、IDC10芯下载线一根、JTAG(EC-3/5)仿真器一个、C8051F410单片机学习板主板一块。
8051系列单片机C程序设计完全手册

8051系列单片机C程序设计完全手册(实事求是编著)目录第1章单片机基础1.1 单片机技术发展状况1.2 51系列单片机体系结构1.2.1 内部结构1.2.2 存储器组织结构l.2.3 内部功能模块l.2.4 外部引脚1.2.5 系统资源扩展1.3 单片机的编程方法第2章 C语言编程基础2.1 基本概念2.1.1 概述2.1.2 变量与算术表达式2.1.3 for语句2.1.4 符号常量2.2 数据类型、运算符和表达式2.2.1 C语言的数据类型2.2.2 常量与变量2.2.3 整型数据2.2.4 实型数据2.2.5 字符型数据2.2.6 运算符2.2.7 表达式2.3 程序控制语句2.3.1 程序的3种基本结构2.3.2 条件控制语句2.3.3 程序应用举例2.4 循环控制语句2.4.1 while语句2.4.2 dowhile语句2.4.3 for语句2.4.4 break与continue语句2.4.5 程序应用举例2.5 小结第3章 C语言高级编程3.1 函数与程序结构3.1.1 函数的基本知识3.1.2 返回非整数值的函数3.1.3 外部变量3.1.4 作用域规则3.1.5 头文件3.1.6 静态变量3.1.7 寄存器变量3.1.8 分程序结构3.1.9 初始化3.1.10 递归3.2 数组3.2.1 一维数组3.2.2 维数组3.2.3 多维数组3.2.4 数组的初始化3.3 指针3.3.1 指针与指针变量.3.3.2 指针变量的定义与引用3.3.3 指针运算符与指针表达式3.3.4 指针与数组3.3.5 指针的地址分配3.3.6 指针数组3.3.7 指向指针的指针3.4 占构体与共用体3.4.1 结构体类型变量的定义和引用3.4.2 结构体数组的定义和引用3.4.3 结构体指针的定义和引用3.4.4 共用体3.5 小结第4章C51程序设计4.1 C51对标准C语言的扩展4.1.1 存储区域4.1.2 数据变量分类4.1.3 存储器模式4.1.4 绝对地址的访问4.1.5 指针4.1.6 函数4.2 C5 1函数库4.2.1 字符函数CTYPE.H4.2.2 一般I/O函数STDIO.H4.2.3 字符串函数STRING.H4.2.4 标准函数STDLIB.H4.2.5 数学函数MATH.H4.2.6 绝对地址访问ABSACC.H4.2.7 内部函数INTRINS.H4.2.8 变量参数表STDARG.H4.2.9 全程跳转SETJMPH4.2.10 访问SFR和SFR bit地址REGxxx.H4.3 C51程序编写4.3.1 C程序基本结构4.3.2 编写高效的C51程序及优化程序第5章 Windows集成开发环境μVision25.1 μVision2编辑界面及其功能介绍5.1.1 μVision2界面综述5.1.2 主菜单栏5.1.3 μVision2功能按钮5.1.4 μVision2窗口环境5.2 应用μVision2开发流程介绍5.2.1 建立新项目5.2.2 常用环境配置5.2.3 代码优化5.2.4 目标代码调试5.3 CPU仿真5.3.1 μVision2调试器5.3.2 调试命令5.3.3 存储器空间5.3.4 表述(Expressions)5.3.5 技巧5.4 深入了解μVision25.4.1 μVision2的项目管理5.4.2 使用技巧5.4.3 μVision2调试函数第6章 C5l编译器6.1 预处理6.1.1 宏定义6.1.2 文件包含6.1.3 条件编译6.1.4 其他预处理命令6.2 C51编译器控制指令详解6.2.1 源控制指令6.2.2 列表控制指令6.2.3 目标控制指令6.3 C5l的高级配置文件6.3.1 目标程序启动配置文件——STARTUP.A51.6.3.2 CPU初始化文件——START751.A516.3.3 静态变量初始化文件——INT.A516.3.4 专用变量初始化文件——INIT751.A51第7章 C51的典型资源编程7.1 中断系统设计7.2 定时/计数器的使用7.3 I/O口的使用7.4 扩展存储器7.4.1 外部ROM7.4.2 外部RAM7.4.3 外部串行E2PROM7.5 一个使用多种资源的完整例程7.5.1 项目需求7.5.2 步进电机背景知识7.5.3 解决方案设计与实现第8章单片机通信8.1 串口通信8.1.1 串行通信基础8.1.2 单片机串口使用8.2 单片机点对点通信8.2.1 通信接口设计8.2.2 单片机点对点通信程序设计8.3 单片机多机通信8.3.1 主机部分通信程序设计8.3.2 从机部分通信程序设计8.4 单片机I2C总线通信8.4.1 I2C总线介绍8.4.2 I2C总线硬件接口设计8.4.3 I2C总线模拟硬件接口软件设计8.4.4 I2C总线系统的设计要点8.5 单片机与计算机的互连8.5.1 电路设计8.5.2电路的C5 1程序代码8.5.3计算机端的Visual C++程序代码第9章 C51单片机的工程开发实例9.1 单片机系统设计方法9.2 C51系统设计的相关知识9.2.1 硬件以及电路的知识9.2.2 软件以及编程语言的知识9.3 C5l系统设计需要注意的一些问题9.3.1 单片机资源的分配9.3.2 单片机的寻址9.3.3 C5 1函数的返回值9.3.4 单片机的看门狗功能9.3.5 单片机的外设9.3.6 单片机的功耗9.4 有关C51的一些问题9.5 键盘和发光数码管显示9.5.1 电路设计的背景及功能9.5.2 电路的设计9.5.3 键盘扫描电路的C51程序代码9.5.4 电路的改进——键盘的消抖动程序9.5.5 电路的显示部分-LED数码管电路9.6 A/D、D/A转换器使用9.6.1 电路设计的背景及功能9.6.2 电路的设计9.6.3 电路的C51程序代码9.7 基于单片机的数字钟9.7.1 电路设计的背景及功能9.7.2 电路的设计9.7.3 电路的C51程序代码第10章 C5l单片机典型模块实例10.1 典型外部ROM和RAM器件的使用10.1.1 实例功能10.1.2 器件和原理10.1.3 电路10.1.4 程序设计10.2 液晶显示和驱动实例10.2.1 实例功能10.2.2 器件和原理10.2.3 电路lO.2.4 程序设计10.3 用A/D芯片进行电压测量10.3.1 实例功能10.3.2 器件和原理10.3.3 电路10.3.4 程序设计lO.4 使用DSl820进行温度补偿和测量10.4.1 实例功能10.4.2 器件和原理10.4.3 电路10.4.4 程序设计10.5 语音芯片在单片机系统中的使用10.5.1 实例功能10.5.2 器件和原理10.5.3 电路10.5.4 程序设计10.6 时钟芯片在单片机系统中的应用10.6.1 实例功能10.6.2 器件和原理10.6.3 电路10.6.4 程序设计10.7 单片机中滤波算法的实现10.8 信号数据的FFT变换。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
编译:陈拓 chentuo2000@
2009年9月2日
MC8051 IP核可综合 VHDL 微控制器 IP-Core
用户指南
Web: http://oregano.at/services/8051.htm
Contact: mc8051@oregano.at
Version 1.1
June 2002
8051 IP核 - 概述
关键特性
y全可综合设计
y指令集兼容工业标准8051微控制器
y优化的架构是该核达到每操作码1到4个时钟
y使用全新架构速度更快至10倍
y用户可选择定时器/计数器以及串口单元的数目
y活动定时器/计数器以及串口单元可以通过特殊功能寄存器选择
y使用并行乘法器单元优化乘法命令(MUL)的实现
y使用并行除法器单元优化除法命令(MUL)的实现
y无复用的I/O端口
y256K字节的内部RAM
y多至64K字节ROM和多至64K字节RAM
y源代码在GNU LGPL许可证下可以自由修改
y技术独立,结构清晰,注释良好的VHDL源码
y通过调整/修改VHDL源码易于扩展
y通过VHDL常量可参数化
8051 IP核-方块图
顶层模块及其子模块描绘于图1。
图1:8051微控制器IP核的方块图
表1:顶层设计名字
设计层次
设计层次和相应的VHDL文件描绘于图2。
图2:8051微控制器IP核的设计层次
VHDL源文件在整个设计中统一命名:
y VHDL实体 entity-name_.vhd
y VHDL构造 entity-name_rtl.vhd用于包含逻辑的模块
entity-name_struc.vhd用于仅连接子模块的模块
y VHDL配置 entity-name_rtl_cfg.vhd
entity-name_struc_cfg.vhd
核本身由子模块、定时器/计数器、算数逻辑单元AUL、串口和控制单元组成。
RAN和ROM块的生成通常与所选择的目标技术相对应,并因此在最高设计层次被实例化。
生成的RAM块和BIST结构 - 用于ASIC生产测试集成 - 可以容易地在该设计层次添加。
时钟域
IP核是一个全同步的设计。
有一个单一的信号时钟控制每个存储单元的时钟输入。
8051
未使用时钟门控。
时钟信号不反馈到任何组合元件。
中断输入线用标准的两级同步阶段被同步到全局时钟信号,因为它们可能被用另一个时钟操作的外部电路所驱动。
并口输入信号不用这种方式同步,如果用户决定需要同步这些信号,它也可以容易地被添加。
存储器接口
由于优化的架构,从存储器块来去的信号没有被寄存。
所以在同步输入和输出期间定时
约束应该被放置在相应的端口上,并且同步存储器块应该被用于mc8051 IP核。
配置8051 IP核
下面将讨论8051微控制器IP核的参数化设计,并且将给出在大设计中嵌入IP核的信息。
定时器/计数器,串口和中断
原始的微控制器设计只提供2个定时器/计数器,1个串口和2个外部中断源,而面派生的8051在片上提供更多的资源。
但有时这是一个限制因素,因此我们决定在8051 IP核中实现一些可参数化的端口。
该8051微控制器IP核简单地用改变VHDL实例的值的方法提供能产生多至256个各种单元的能力。
在VHDL源文件mc8051_p.vhd中包含的C_IMPL_N_TMR可以从1到256取值以控制该特性。
组成这些间隔结果的值在核的非功能配置中。
图3显示了VHDL代码相应的行。
图3:用于配置定时器/计数器单元,串口和外部中断的VHDL源代码 不能同时单独改变3个常量C_IMPL_N_TMR,C_IMPL_N_SIU,C_IMPL_N_EXT。
常量C_IMPL_N_TMR每增加1意味着多生成2个附加的定时器/计数器单元,一个附加的串口和2个附加的外部中断源。
为了能够访问到所有已生成单元的寄存器,而不改变微控制器的地址空间,仅有的2个8位寄存器被推断为特殊功能寄存器,它们是TSEL(地址0x8Eh用于定时器/计数器单元)和SSEL(地址0x9Ah用于串口单元)。
如果这些寄存器指向一个不存在的设备号,默认单元号1将被选择。
电路描绘在图4中。
图4:通过附加的TSEL寄存器选择一个TCON寄存器
如果在这个特殊的器件没有被TSEL选择期间发生一个中断,相应的中断标志保持置位直到匹配的中断服务例程被执行。
在器件还没有被选择的这段时间内的随后的中断,仅有一个信号调用中断服务例程。
可选指令
在某些情况下不实现那些不需要而且消耗许多芯片面积的指令是有意义的。
这些指令是8位乘法器,8位除法器和8位十进制校正。
因此在mc8051_p.vdl源文件中的VHDL常量C_IMPL_MUL被设置为0时,用于8位乘法的MUL指令可以被跳过。
同样通过设置VHDL 常量C_IMPL_DIV为0时,8位除法DIV可以被跳过。
设置常量C_IMPL_DA为0时,十进制校正指令可以被跳过。
VHDL源代码相应的行见图5。
图5:显示指令怎样被跳过的代码片段
如果3个可选指令都不实现,可节省10%的芯片面积。
并行I/O端口
IP核仅提供原始的8051微控制器的4个双向8位I/O端口以方便与微控制器的 mc8051
环境交换数据。
为了在IC设计中易于集成我们的核,原始的多功能端口不必重新构建并且所有信号(例如,串口,中断,计数器输入和外部存储器接口)都已经被分别馈送到核的输出(见图1)。
并行I/O端口的基本结构示于图6。
图6:并行I/O端口的基本结构
校验
核的校验由VHDL代码的仿真实现,并用由工业标准的8051仿真产生的结果和执行程序的结果(例如ROM的内容)相比较(/demo/evaldl.asp?p=C51)。
在仿真之后,一些确定的存储器区域的内容被写到一个文件中,既用于标准的8051仿真(使用命令sava keil.hex 0x00, 0xFF)也用于VHDL代码仿真(例如,使用脚本write2file.do,在仿真目录中产生文件regs.log)。
作为结果文本文件必须完全一致。
为了能够从Keil开发软件馈送编译好的汇编文件到VHDL代码仿真一个在最后发布的IP核中提供的短C程序,要转换Intel的hex格式文件到一个包含8位数据的文本文件,以适合被VHDL仿真器读取(文件mc8051_rom.dua在仿真目录中)。
交付使用
解压mc8051.zip文件使用如我们建议的目录树。
已经有用于综合的脚本,有使用Synopsys的用于ASIC设计的DesignCompiler脚本和Synplicity的用于FPGA设计的脚本,还有使用Mentor/Modeltech的Modelsim的用于RTL仿真的脚本。
图7是mc8051目录树图。
图7:mc8051 IP核发布的目录树
表2:目录树:简单描述
文档版本。