- #include <STC8H.H>
- #include "define.h"
- #include <intrins.h>
- #include <stdio.h>
- #include <string.h>
- #include <absacc.h>
-
- #define COM0 P20
- #define COM1 P21
- #define COM2 P22
- #define COM3 P23
- #define COM4 P24
- #define COM5 P25
- #define COM6 P26
- #define COM7 P27
- #define SEG0 P40
- #define SEG1 P41
- #define SEG2 P42
- #define SEG3 P43
- #define SEG4 P44
- #define SEG5 P45
- #define SEG6 P46
- #define SEG7 P47
- #define SEG8 P00
- #define SEG9 P01
- #define SEGA P02
- #define SEGB P03
- #define SEGC P34
- #define SEGD P35
- #define SEGE P36
- #define SEGF P37
-
- unsigned char Colon;
-
- unsigned int code Seg_Table[36]=
- {
- 0x003F,0x0006,0x00DB,0x00CF,0x00E6,0x00ED,0x00FD,0x0007,0x00FF,
- 0x00EF,0x00F7,0x128F,0x0039,0x120F,0x00F9,0x00F1,0x00BD,0x00F6,
- 0x1209,0x001E,0x2470,0x0038,0x1536,0x2136,0x00DC,0x00F3,0x203F,
- 0x20F3,0x00ED,0x1201,0x003E,0x0C30,0x2A36,0x2D00,0x1500,0x0C09
- };
-
-
- /*----------------------------延时10us@STC-Y6@11.0592MHz----------------------------*/
- //void Delay_10us(void)
- //{
- // unsigned char i;
- // i=35;
- // while(--i);
- //}
-
- /*----------------------------延时x10us----------------------------*/
- //void Delay_x10us(unsigned char x)
- //{
- // while(x--)
- // Delay_10us();
- //}
-
- /*----------------------------延时10ms@STC-Y6@11.0592MHz----------------------------*/
- //void Delay_10ms(void)
- //{
- // unsigned char i,j;
- // _nop_();
- // _nop_();
- // i=144;
- // j=157;
- // do
- // {
- // while(--j);
- // }while(--i);
- //}
-
- /*----------------------------延时x10ms----------------------------*/
- //void Delay_x10ms(unsigned char x)
- //{
- // while(x--)
- // Delay_10ms();
- //}
-
- unsigned int Text_Decode(unsigned char text)
- {
- unsigned int temp;
- if(text>='0'&&text<='9')
- temp=Seg_Table[text-'0'];
- else if(text>='a'&&text<='z')
- temp=Seg_Table[text-'a'+10];
- else if(text>='A'&&text<='Z')
- temp=Seg_Table[text-'A'+10];
- else
- temp=0x0000;
- return temp;
- }
-
- void Display_Text(unsigned char *text_pointer)
- {
- unsigned char i;
- unsigned char xdata *xfr_pointer=XBYTE+0xfb10;
- for(i=0;i<8;i++)
- {
- *(xfr_pointer+i)=Text_Decode(*(text_pointer+i))&0xFF;
- *(xfr_pointer+8+i)=Text_Decode(*(text_pointer+i))>>8;
- *(xfr_pointer+16+i)=Text_Decode(*(text_pointer+i+8))&0xFF;
- *(xfr_pointer+24+i)=Text_Decode(*(text_pointer+i+8))>>8;
- if(i==0&&Colon&0x01)
- {
- *(xfr_pointer+8+i)|=0x40;
- }
- if(i==0&&Colon&0x04)
- {
- *(xfr_pointer+24+i)|=0x40;
- }
- if(i==4&&Colon&0x02)
- {
- *(xfr_pointer+8+i)|=0x40;
- }
- if(i==4&&Colon&0x08)
- {
- *(xfr_pointer+24+i)|=0x40;
- }
- }
- }
-
- void Init(void)
- {
- P_SW2|=EAXFR;
- P0M0=0x0F;
- P0M1=0x00;
- P1M0=0x00;
- P1M1=0x00;
- P2M0=0xFF;
- P2M1=0x00;
- P3M0=0xF0;
- P3M1=0x00;
- P4M0=0xFF;
- P4M1=0x00;
- P5M0=0x00;
- P5M1=0x00;
- P6M0=0x00;
- P6M1=0x00;
- P7M0=0x00;
- P7M1=0x00;
- P2DR=0x00;
-
- COMEN=0xFF;
- SEGENL=0xFF;
- SEGENH=0x7F;
- LEDCTRL=0xA0;
- LEDCKS=0x00;
-
- EA=1;
-
- COM0_DA_L=0x00;
- COM0_DA_H=0x00;
- COM1_DA_L=0x00;
- COM1_DA_H=0x00;
- COM2_DA_L=0x00;
- COM2_DA_H=0x00;
- COM3_DA_L=0x00;
- COM3_DA_H=0x00;
- COM4_DA_L=0x00;
- COM4_DA_H=0x00;
- COM5_DA_L=0x00;
- COM5_DA_H=0x00;
- COM6_DA_L=0x00;
- COM6_DA_H=0x00;
- COM7_DA_L=0x00;
- COM7_DA_H=0x00;
- COM0_DC_L=0x00;
- COM0_DC_H=0x00;
- COM1_DC_L=0x00;
- COM1_DC_H=0x00;
- COM2_DC_L=0x00;
- COM2_DC_H=0x00;
- COM3_DC_L=0x00;
- COM3_DC_H=0x00;
- COM4_DC_L=0x00;
- COM4_DC_H=0x00;
- COM5_DC_L=0x00;
- COM5_DC_H=0x00;
- COM6_DC_L=0x00;
- COM6_DC_H=0x00;
- COM7_DC_L=0x00;
- COM7_DC_H=0x00;
- }
-
- void main(void)
- {
- Init();
- Colon=0x00;
- Display_Text("STC32BIT8051YYDS");
- while(1)
- {
-
- }
- }
复制代码
|