man/machine/interface设计开发环境为ICC,可以编译成汇编,直接下栽到嵌入式avr单片机进行控制

源代码在线查看: rtc.i

软件大小: 213 K
上传用户: m472333662
关键词: interface machine man ICC
下载地址: 免注册下载 普通下载 VIP

相关代码

				#line 1 "C:\DOCUME~1\Administrator\桌面\张军\PS2-ICC\RTC.C"
				#line 1 "C:/icc/include/io8535v.h"
				
				
				
				
				#line 7 "C:/icc/include/io8535v.h"
				
				
				#line 10 "C:/icc/include/io8535v.h"
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				#line 2 "C:\DOCUME~1\Administrator\桌面\张军\PS2-ICC\RTC.C"
				#line 1 "C:/icc/include/macros.h"
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				#line 33 "C:/icc/include/macros.h"
				
				
				
				
				
				
				
				
				
				
				
				void _StackCheck(void);
				void _StackOverflowed(char);
				
				
				
				
				#line 3 "C:\DOCUME~1\Administrator\桌面\张军\PS2-ICC\RTC.C"
				
				
				
				
				
				
				
				 unsigned char F_Flag;
				 unsigned char Table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
				
				void DelayMs(unsigned int i)
				{unsigned char j;
				 for(;i!=0;i--)
				  {for(j=2000;j!=0;j--) {;}}
				}
				
				void Display(unsigned char *p)
				{unsigned char i,sel=0x01;
				 for(i=0;i				  {(*(volatile unsigned char *)0x38)=~sel;
				(*(volatile unsigned char *)0x3B)=Table[*p];
				   p++;
				   DelayMs(20);
				   sel=sel				  }
				}
				
				
				void NOPNOP(unsigned char i)
				{for(;i!=0;i--)asm("nop");}
				
				
				void SetSCL(unsigned char i)
				{if(i==1)(*(volatile unsigned char *)0x35)=(*(volatile unsigned char *)0x35)|0x01;
				 else(*(volatile unsigned char *)0x35)=(*(volatile unsigned char *)0x35)&0xfe;}
				
				
				void SetSDA(unsigned char i)
				{if(i==1)(*(volatile unsigned char *)0x35)=(*(volatile unsigned char *)0x35)|0x02;
				 else(*(volatile unsigned char *)0x35)=(*(volatile unsigned char *)0x35)&0xfd;}
				 K
				
				
				
				void Start()
				{SetSDA(1);
				 SetSCL(1);
				 NOPNOP(50);
				
				
				 SetSDA(0);
				  NOPNOP(50);
				
				
				
				
				 SetSCL(0);
				}
				
				void Stop()
				{SetSDA(0);
				 SetSCL(1);
				 NOPNOP(50);
				
				
				 SetSDA(1);
				 NOPNOP(50);
				
				
				
				
				 SetSCL(0);
				}
				
				void Ack()
				{SetSDA(0);
				 SetSCL(1);
				 NOPNOP(50);
				
				
				
				
				 SetSCL(0);
				 SetSDA(1);
				}
				
				void Nack()
				{SetSDA(1);
				 SetSCL(1);
				 NOPNOP(50);
				
				
				
				
				 SetSCL(0);
				 SetSDA(0);
				}
				
				void Check_Ack()
				{SetSDA(1);
				 SetSCL(1);
				 F_Flag=0;
				(*(volatile unsigned char *)0x34)=(*(volatile unsigned char *)0x34)&0xfd;
				
				 if(((*(volatile unsigned char *)0x33)&0x02)==0)
				   {
				        SetSCL(0);
				        NOPNOP(50);
				
				
				
				
				    }
				 else
				    {
				         F_Flag=1;
				         SetSCL(0);
				         NOPNOP(50);
				
				
				
				
				     }
				(*(volatile unsigned char *)0x34)=(*(volatile unsigned char *)0x34)|0x02;
				}
				
				void Write_Bit0()
				{SetSDA(0);
				 SetSCL(1);
				 NOPNOP(50);
				
				
				
				
				 SetSCL(0);
				}
				
				void Write_Bit1()
				{SetSDA(1);
				 SetSCL(1);
				 NOPNOP(50);
				
				
				
				
				 SetSCL(0);
				 SetSDA(0);
				}
				
				void Write_Byte(unsigned char Data)
				{unsigned char i;
				 for(i=0;i				   {if((Data&0x80)>0)
				         Write_Bit1();
				    else
				         Write_Bit0();
				    Data				    }
				}
				
				
				 unsigned char Read_Byte()
				{unsigned char nn=0xff;
				 unsigned char j;
				 for (j=0;j				    {SetSDA(1);
				     SetSCL(1);
				(*(volatile unsigned char *)0x34)=(*(volatile unsigned char *)0x34)&0xfd;
				
				       if(((*(volatile unsigned char *)0x33)&0x02)==0)
					    {nn				         nn=(nn&0xfe);
				         SetSCL(0);}
				     else
				        {nn				         nn=(nn|0x01);
				         SetSCL(0);}
				    }
				(*(volatile unsigned char *)0x34)=(*(volatile unsigned char *)0x34)|0x02;
				 return(nn);
				}
				
				
				
				
				
				
				
				void Write_Nbyte(unsigned char Slave,unsigned char Address,unsigned char *Array,unsigned char Number)
				{unsigned char k;
				 writ:do
				    {Start();
				     Write_Byte(Slave);
				     Check_Ack();
				    }while(F_Flag==1);
				   do
				    {Write_Byte(Address				     Check_Ack();
				    }while(F_Flag==1);
				   for(k=0;k				    {Write_Byte(*Array);
					 Array++;
				     Check_Ack();
				
					 }
				   Stop();
				}
				
				
				void Write_1byte(unsigned char Slave,unsigned char Address,unsigned char Data)
				{writ:do
				    {Start();
				     Write_Byte(Slave);
				     Check_Ack();
				    }while(F_Flag==1);
				   do
				    {Write_Byte(Address				     Check_Ack();
				    }while(F_Flag==1);
				   Write_Byte(Data);
				   Check_Ack();
				
				   Stop();
				}
				
				
				
				
				
				
				
				
				void Read_Nbyte(unsigned char Slave,unsigned char Address,unsigned char *Array,unsigned char Number)
				{unsigned char data0,x;
				
					do{Start();Write_Byte(Slave);Check_Ack();}while(F_Flag==1);
				
				    do {Write_Byte(Address				
				    do{Start();Write_Byte(Slave+1);Check_Ack();}while(F_Flag==1);
				
				    for(x=0;x				     {data0=Read_Byte();*Array=data0;Array++;
					  if(x				    Nack();
				
				    Stop();
				}
				
				void main(void)
				{unsigned char i;
				 unsigned char time[15]={2,0,0,4,1,2,2,7,1,1,7,3,0,5,0};
				 unsigned char Set_Time[7]={0x50,0x30,0x17,0x01,0x27,0x12,0x04};
				
				 unsigned char SD2303_Controller1=0x00;
				 unsigned char SD2303_Controller2=0x20;
				
				(*(volatile unsigned char *)0x3A)=0xff;
				(*(volatile unsigned char *)0x37)=0xff;
				(*(volatile unsigned char *)0x34)=0xFF;
				 Write_1byte(0x64,0x0e,SD2303_Controller1);
				 Write_1byte(0x64,0x0f,SD2303_Controller2);
				 Write_Nbyte(0x64,0x00,Set_Time,7);
				
				 while(1)
					{Read_Nbyte(0x64,0x00,Set_Time,7);
				     time[2]=Set_Time[6]>>4;
					 time[3]=Set_Time[6]&0x0f;
					 time[4]=Set_Time[5]>>4;
				     time[5]=Set_Time[5]&0x0f;
					 time[6]=Set_Time[4]>>4;
					 time[7]=Set_Time[4]&0x0f;
					 time[8]=Set_Time[3];
					 time[9]=Set_Time[2]>>4;
					 time[10]=Set_Time[2]&0x0f;
					 time[11]=Set_Time[1]>>4;
				     time[12]=Set_Time[1]&0x0f;
					 time[13]=Set_Time[0]>>4;
					 time[14]=Set_Time[0]&0x0f;
					 for(i=0;i					 	 Display(time);
				     for(i=0;i					 	 Display(time+4);
					 for(i=0;i					 	 Display(time+9);
					 for(i=0;i					 	 Display(time+11);
					Display(time);
				
				  }
				}
				
							

相关资源