⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 12887.c

📁 c8051最小系统板的个部分调试
💻 C
字号:
#include "C8051F120.h"
#define uchar unsigned char
#define uint unsigned int

#include <stdio.h>
#include <absacc.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>	 




#define P128870 XBYTE[0xff00]
#define P128871 XBYTE[0xff01]
#define P128872 XBYTE[0xff02]
#define P128873 XBYTE[0xff03]
#define P128874 XBYTE[0xff04]
#define P128875 XBYTE[0xff05]
#define P128876 XBYTE[0xff06]
#define P128877 XBYTE[0xff07]
#define P128878 XBYTE[0xff08]
#define P128879 XBYTE[0xff09]
#define P12887a XBYTE[0xff0a]
#define P12887b XBYTE[0xff0b]
#define P12887c XBYTE[0xff0c]
#define P12887d XBYTE[0xff0d]
#define P12887e XBYTE[0xff0e]
#define P12887f XBYTE[0xff0f] 
void delay(unsigned int t)
 {
  unsigned int i,j;
  for(i=0;i<t;i++)
  for(j=0;j<1;j++);
}					 
 

// Peripheral specific initialization functions,
// Called from the Init_Device() function
void EMI_Init()
{
    SFRPAGE   = EMI0_PAGE;
    EMI0CF    = 0x27;
}

void Port_IO_Init()
{
    

    SFRPAGE   = CONFIG_PAGE;
    


    XBR2      = 0x40;
}

 void Oscillator_Init()
{
    SFRPAGE   = CONFIG_PAGE;
    OSCICN    = 0x83;
}


void Init_Device(void)
{	void Oscillator_Init();
    EMI_Init();
    Port_IO_Init();
}

	  


void setup12887(void)  //设置系统时间
{
    uchar i; EMI0CF    = 0x27;
    i=P12887d; 
    P12887a=0x70;    P12887b=0x82;    P128870=0x01;    P128871=0x00;    P128872=0x01;
    P128873=0x00;    P128874=0x15;    P128875=0x00;    P128876=0x04;    P128877=0x25;
    P128878=0x07;    P128879=0x07;    P12887b=0x12;    P12887a=0x20;
    i=P12887c;	 EMI0CF    = 0x37;
}
void read12887(uchar *p)   //读取系统时间

   { uchar a; EMI0CF    = 0x27;
 
   do{a=P12887a; }
	while((a&0x80)==0x80);
    *p++=P128870; *p++=P128872; *p++=P128874; *p++=P128876;
    *p++=P128877; *p++=P128878; *p++=P128879;  EMI0CF    = 0x37;
}
void start12887(void)      //启动时钟
{
    uchar i;EMI0CF    = 0x27;
    i=P12887d;
    P12887a=0x70; 
	P12887b=0x82; 
	P128871=0x00;   
	P128873=0x00;   
	P128875=0x00;  
    P12887b=0x12;    
	P12887a=0x20;  
    i=P12887c; 	 EMI0CF    = 0x37;
}


main()
{
unsigned char *p,pp;
unsigned int i,j;
WDTCN=0xde;
WDTCN=0xad;


Init_Device( );
p=0x30;
setup12887();
start12887();
P5=0x8f;   
 
read12887(p);


delay(1);
 read12887(p);



 
 
 read12887(p);
 
 
 read12887(p);
 delay(10);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -