STC12C5A60S2 AD引脚电压测量

单片机ADC功能电压测量

使用STC12C5A60S2测量引脚电压

官网给出的代码运行后可以在串口工具中看到电压的输出,由于需要把单片机与电脑连接,电脑则会直接给单片机供电,所以电压值不会改变。所以需要单独一块电池或使用可编程电源给单片机供电,然后连接一块屏幕用来显示。这样就能看到测量出的电压,再通过官网给出的公式来计算电压。

STC官网中贴出的电压测试代码:

 /*------------------------------------------------------------------*/
    /* --- STC MCU International Limited -------------------------------*/
    /* --- STC 1T Series MCU A/D Conversion Demo -----------------------*/
    /* --- Mobile: (86)13922805190 -------------------------------------*/
    /* --- Fax: 86-755-82944243 ----------------------------------------*/
    /* --- Tel: 86-755-82948412 ----------------------------------------*/
    /* --- Web: www.STCMCU.com -----------------------------------------*/
    /* If you want to use the program or the program referenced in the  */
    /* article, please specify in which data and procedures from STC    */
    /*------------------------------------------------------------------*/
    
    #include "reg51.h"
    #include "intrins.h"
    
    #define FOSC    11059200L
    #define BAUD    9600
    
    typedef unsigned char BYTE;
    typedef unsigned int WORD;
    
    /*Declare SFR associated with the ADC */
    sfr ADC_CONTR   =   0xBC;           //ADC control register
    sfr ADC_RES     =   0xBD;           //ADC high 8-bit result register
    sfr ADC_LOW2    =   0xBE;           //ADC low 2-bit result register
    sfr P1ASF       =   0x9D;           //P1 secondary function control register
    
    /*Define ADC operation const for ADC_CONTR*/
    #define ADC_POWER   0x80            //ADC power control bit
    #define ADC_FLAG    0x10            //ADC complete flag
    #define ADC_START   0x08            //ADC start control bit
    #define ADC_SPEEDLL 0x00            //420 clocks
    #define ADC_SPEEDL  0x20            //280 clocks
    #define ADC_SPEEDH  0x40            //140 clocks
    #define ADC_SPEEDHH 0x60            //70 clocks
    
    void InitUart();
    void InitADC();
    void SendData(BYTE dat);
    BYTE GetADCResult(BYTE ch);
    void Delay(WORD n);
    void ShowResult(BYTE ch);
    void main()
    {
        InitUart();                     //Init UART, use to show ADC result
        InitADC();                      //Init ADC sfr
        while (1)
        {
            ShowResult(0);              //Show Channel0
    			  Delay(5);
    //        ShowResult(1);              //Show Channel1
    //        ShowResult(2);              //Show Channel2
    //        ShowResult(3);              //Show Channel3
    //        ShowResult(4);              //Show Channel4
    //        ShowResult(5);              //Show Channel5
    //        ShowResult(6);              //Show Channel6
    //        ShowResult(7);              //Show Channel7
        }
    }
    
    /*----------------------------
    Send ADC result to UART
    ----------------------------*/
    void ShowResult(BYTE ch)
    {
        SendData(ch);   	//Show Channel NO.
        SendData(GetADCResult(ch));     //Show ADC high 8-bit result
    //if you want show 10-bit result, uncomment next line
        //SendData(ADC_LOW2);             //Show ADC low 2-bit result
    }
    
    /*----------------------------
    Get ADC result
    ----------------------------*/
    BYTE GetADCResult(BYTE ch)
    {
        ADC_CONTR = ADC_POWER | ADC_SPEEDLL | ch | ADC_START;
        _nop_();                        //Must wait before inquiry
        _nop_();
        _nop_();
        _nop_();
        while (!(ADC_CONTR & ADC_FLAG));//Wait complete flag
        ADC_CONTR &= ~ADC_FLAG;         //Close ADC
    
        return ADC_RES;                 //Return ADC result
    }
    
    /*----------------------------
    Initial UART
    ----------------------------*/
    void InitUart()
    {
        SCON = 0x5a;                    //8 bit data ,no parity bit
        TMOD = 0x20;                    //T1 as 8-bit auto reload
        TH1 = TL1 = -(FOSC/12/32/BAUD); //Set Uart baudrate
        TR1 = 1;                        //T1 start running
    }
    
    /*----------------------------
    Initial ADC sfr
    ----------------------------*/
    void InitADC()
    {
        P1ASF = 0x01;                   //Open 8 channels ADC function
        ADC_RES = 0;                    //Clear previous result
        ADC_CONTR = ADC_POWER | ADC_SPEEDLL;
        Delay(2);                       //ADC power-on and delay
    }
    
    /*----------------------------
    Send one byte data to PC
    Input: dat (UART data)
    Output:-
    ----------------------------*/
    void SendData(BYTE dat)
    {
        while (!TI);                    //Wait for the previous data is sent
        TI = 0;                         //Clear TI flag 
        SBUF = dat;                     //Send current data
    }
    
    /*----------------------------
    Software delay function
    ----------------------------*/
    void Delay(WORD n)
    {
        WORD x;
    
        while (n--)
        {
            x = 5000;
            while (x--);
        }
    }

1.先将单片机与屏幕电池正确连接,测试屏幕,使用屏幕测试代码

2.屏幕为JLX12864G-542-BN(删减掉测试图片,保留一种ASCII字库显示数据)

3.把屏幕显示与电压测量代码糅合在一起,把电压显示到屏幕上

4.记录电压值,使用官方文档中的电压计算公式计算
官网文档公式
5.用万用表测量ADC引脚电压,计算值做对比,验证测试准确性

#include <STC12C5A60S2.H>
#include "intrins.h"

#define uchar unsigned char

#define uint unsigned int

#define ulong unsigned long 
	

#define FOSC    11059200L
#define BAUD    9600


typedef unsigned char BYTE;
typedef unsigned int WORD;

uchar o,p,q,*m,*e,*f;

//sfr ADC_CONTR   =   0xBC;           //ADC control register
//sfr ADC_RES     =   0xBD;           //ADC high 8-bit result register
sfr ADC_LOW2    =   0xBE;           //ADC low 2-bit result register
//sfr P1ASF       =   0x9D;           //P1 secondary function control register

/*Define ADC operation const for ADC_CONTR*/
#define ADC_POWER   0x80            //ADC power control bit
#define ADC_FLAG    0x10            //ADC complete flag
#define ADC_START   0x08            //ADC start control bit
#define ADC_SPEEDLL 0x00            //420 clocks
#define ADC_SPEEDL  0x20            //280 clocks
#define ADC_SPEEDH  0x40            //140 clocks
#define ADC_SPEEDHH 0x60            //70 clocks

void InitUart();
void InitADC();
void SendData(BYTE dat);
BYTE GetADCResult(BYTE ch);
void Delay(WORD n);
void ShowResult(BYTE ch);

sbit lcd_cs1	=P3^6;	//????,CS:??	
sbit lcd_reset	=P3^7;	//????,RESET:??	
sbit lcd_rs	=P3^4;	//????,RS:??/??????????"A0",?揅D?
sbit lcd_e	=P3^3;	//????,E:??????	
sbit lcd_rw	=P3^2;	//????,R/W:?/?	
sbit key	=P2^0;	//????,P2.0 ?? GND ???????	
//?? P1.0~1.7 ?? DB0~DB7		
			

uchar code ascii_table_8x16[95][16];

void delay(int i)

{

		int j,k;

		for(j=0;j<i;j++)

		for(k=0;k<110;k++);


}


void delay_us(int i)

{

	int j,k;

	for(j=0;j<i;j++)

	for(k=0;k<1;k++);

}

void waitkey()


{

	repeat:	if(key==1) goto repeat;

	else	delay(2000);

}


void transfer_command(int data1)

{


		lcd_cs1=0;

		lcd_rs=0;

		lcd_e=0;

		lcd_rw=0;

		P0=data1;

		lcd_e=1;

		delay_us(2);

		lcd_cs1=1;

		lcd_e=0;

}

void transfer_data(int data1)
{

	lcd_cs1=0;

	lcd_rs=1;

	lcd_e=0;

	lcd_rw=0;


	P0=data1;

	lcd_e=1;

	delay_us(2);


	lcd_cs1=1;


	lcd_e=0;

}
		
void initial_lcd()				
{				
		lcd_reset=0;	//?????		
		delay(200);				
		lcd_reset=1;		//????		
		delay(20);				
		transfer_command(0xe2);	//???		
		delay(50);				
		transfer_command(0x2c);	//???? 1:????		
		delay(50);				
		transfer_command(0x2e);	//???? 2:??????????	
		delay(50);				
		transfer_command(0x2f);	//???? 3:????????????????	
		delay(50);				
		transfer_command(0x24);	//?????,????? 0x20~0x27	
		transfer_command(0x81);	//?????		
		transfer_command(0x2A);	//0x1A,???????,????? 0x00~0x3f	
		transfer_command(0xa2);	//1/9 ???(bias)		
		transfer_command(0xc8);	//?????:????		
		transfer_command(0xa0);	//?????:????		
		transfer_command(0x40);	//?????:0X40 ???? 1 ???,0x41:? 2 ?.
		transfer_command(0xaf);	//????		
}				

void lcd_address(uchar page,uchar column)		
{				
		column=column;				
		page=page-1;			//??????? 1 ?,??? IC ???? 0 ?,??????? 1
		transfer_command(0xb0+page);	//????????? 8 ??????? 64 ???? 8 ???
		transfer_command(((column>>4)&0x0f)+0x10);   //??????? 4 ?	
		transfer_command(column&0x0f);	//??????? 4 ?	
}				
//????				
void clear_screen()				
{				
	unsigned char i,j;				
	for(i=0;i<9;i++)		//???? IC ? 65 ?(?? 9 ??),???? 64 ?(8 ?),? 1 ?????,????????
	{				
		lcd_address(1+i,1);

			for(j=0;j<132;j++)	//???? IC ? 132 ?,???? 128 ?,? 4 ?????,??????????
			{

				transfer_data(0x00);//??????? 0,?????

			}
	}
}

void test_display(uchar data1,uchar data2)
{
	int i,j;
	for(j=0;j<8;j++)
	{
		lcd_address(j+1,0);

			for(i=0;i<128;i++)
			{

				transfer_data(data1);

				transfer_data(data2);

			}
	}
}

void display_string_8x16(uint page,uint column,uchar *text)
{
	uint i=0,j,k,n;
	while(text[i]>0x00) 
	{
		if((text[i]>=0x20)&&(text[i]<=0x7e))
		{
			j=text[i]-0x20;
			for(n=0;n<2;n++)
			{
				lcd_address(page+n,column);
				for(k=0;k<8;k++)
				{
					transfer_data(ascii_table_8x16[j][k+8*n]);//?????????,??????+1
				}
			}
			i++;
			column+=8;
		}
		else
		i++;
	}
}
void main(void)		
{		
  InitUart();                     //Init UART, use to show ADC result
  InitADC();                      //Init ADC sfr
	initial_lcd();	//LCD ???	
//	display_string_8x16(1,1," !\"#$%&'()*+,-./");	//?? 8x16 ? ASCII ????
//	display_string_8x16(3,1,"0123456789:;<=>?"); //?????????(???,???,??????)
//	display_string_8x16(5,1,"@ABCDEFGHIJKLMNO");
//	display_string_8x16(7,1,"PQRSTUVWXYZ[\\]^_");	//??:???????(\),???(\)????????(\),????(\)????
		waitkey();
//	clear_screen();
	while(1)
	{
	 ShowResult(0);              //Show Channel0
		waitkey();
		clear_screen();
	}
}

/*----------------------------
Send ADC result to UART
----------------------------*/
void ShowResult(BYTE ch)
{
    //SendData(ch);   	//Show Channel NO.
    SendData(GetADCResult(ch));     //Show ADC high 8-bit result
		
//if you want show 10-bit result, uncomment next line
  //  SendData(ADC_LOW2);             //Show ADC low 2-bit result
}
void SendData(BYTE dat)
{
    while (!TI);                    //Wait for the previous data is sent
    TI = 0;                         //Clear TI flag 
    SBUF = dat;                     //Send current data
		
		p = (dat/100)+0x30;
		o = (dat/10)%10+0x30;
		q = dat%10+0x30;
	
		f = &p;
		m = &o;
		e = &q;

	  display_string_8x16(5,1,f);
		display_string_8x16(5,10,m);
		display_string_8x16(5,19,e);
		display_string_8x16(5,26," ");
}
BYTE GetADCResult(BYTE ch)
{
    ADC_CONTR = ADC_POWER | ADC_SPEEDLL | ch | ADC_START;
    _nop_();                        //Must wait before inquiry
    _nop_();
    _nop_();
    _nop_();
    while (!(ADC_CONTR & ADC_FLAG));//Wait complete flag
    ADC_CONTR &= ~ADC_FLAG;         //Close ADC

    return ADC_RES;                 //Return ADC result
}

/*----------------------------
Initial UART
----------------------------*/
void InitUart()
{
    SCON = 0x5a;                    //8 bit data ,no parity bit
    TMOD = 0x20;                    //T1 as 8-bit auto reload
    TH1 = TL1 = -(FOSC/12/32/BAUD); //Set Uart baudrate
    TR1 = 1;                        //T1 start running
}

/*----------------------------
Initial ADC sfr
----------------------------*/
void InitADC()
{
    P1ASF = 0x01;                   //Open 8 channels ADC function
    ADC_RES = 0;                    //Clear previous result
    ADC_CONTR = ADC_POWER | ADC_SPEEDLL;
    Delay(2);                       //ADC power-on and delay
}



uchar code ascii_table_8x16[95][16]={

/*--  ??:     --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  ??:  !  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,

/*--  ??:  "  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  ??:  #  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,

/*--  ??:  $  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,

/*--  ??:  %  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,

/*--  ??:  &  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,

/*--  ??:  '  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  ??:  (  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,

/*--  ??:  )  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,

/*--  ??:  *  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,

/*--  ??:  +  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,

/*--  ??:  ,  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,

/*--  ??:  -  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

/*--  ??:  .  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,

/*--  ??:  /  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,

/*--  ??:  0  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,

/*--  ??:  1  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

/*--  ??:  2  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,

/*--  ??:  3  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,

/*--  ??:  4  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,

/*--  ??:  5  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,

/*--  ??:  6  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,

/*--  ??:  7  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,

/*--  ??:  8  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,

/*--  ??:  9  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,

/*--  ??:  :  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,

/*--  ??:  ;  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,

/*--  ??:  <  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,

/*--  ??:  =  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,

/*--  ??:  >  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,

/*--  ??:  ?  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,

/*--  ??:  @  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,

/*--  ??:  A  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,

/*--  ??:  B  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,

/*--  ??:  C  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,

/*--  ??:  D  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,

/*--  ??:  E  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,

/*--  ??:  F  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,

/*--  ??:  G  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,

/*--  ??:  H  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,

/*--  ??:  I  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

/*--  ??:  J  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,

/*--  ??:  K  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,

/*--  ??:  L  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,

/*--  ??:  M  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,

/*--  ??:  N  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,

/*--  ??:  O  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,

/*--  ??:  P  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,

/*--  ??:  Q  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,

/*--  ??:  R  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,

/*--  ??:  S  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,

/*--  ??:  T  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,

/*--  ??:  U  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,

/*--  ??:  V  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,

/*--  ??:  W  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,

/*--  ??:  X  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,

/*--  ??:  Y  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,

/*--  ??:  Z  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,

/*--  ??:  [  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,

/*--  ??:  \  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,

/*--  ??:  ]  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,

/*--  ??:  ^  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  ??:  _  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,

/*--  ??:  `  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  ??:  a  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,

/*--  ??:  b  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,

/*--  ??:  c  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,

/*--  ??:  d  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,

/*--  ??:  e  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,

/*--  ??:  f  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

/*--  ??:  g  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,

/*--  ??:  h  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,

/*--  ??:  i  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

/*--  ??:  j  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,

/*--  ??:  k  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,

/*--  ??:  l  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,

/*--  ??:  m  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,

/*--  ??:  n  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,

/*--  ??:  o  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,

/*--  ??:  p  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,

/*--  ??:  q  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,

/*--  ??:  r  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,

/*--  ??:  s  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,

/*--  ??:  t  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,

/*--  ??:  u  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,

/*--  ??:  v  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,

/*--  ??:  w  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,

/*--  ??:  x  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,

/*--  ??:  y  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,

/*--  ??:  z  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,

/*--  ??:  {  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,

/*--  ??:  |  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,

/*--  ??:  }  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,

/*--  ??:  ~  --*/
/*--  Comic Sans MS12;  ??????????:?x?=8x16   --*/
0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

};

注:字符编码方式忘了,所以注释有部分不能用 ~ - ~

本人小白一枚,请做为参考

  • 11
    点赞
  • 45
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
首先,需要在 STC12C5A60S2 上初始化 I2C 总线,并设置好 AD5933 的 I2C 地址(默认为 0x0D)。接着,可以按照以下步骤进行阻抗参数读取: 1. 发送起始信号,并将 AD5933 的地址和写入位发送到 I2C 总线上; 2. 发送阻抗参数读取命令(0x81)到 AD5933 上; 3. 发送重复起始信号,并将 AD5933 的地址和读取位发送到 I2C 总线上; 4. 读取两个字节的阻抗参数; 5. 发送停止信号。 下面是一个简单的示例代码,可以根据实际情况进行修改和优化: ```c #include <reg51.h> #define AD5933_I2C_ADDR 0x0D sbit SDA = P1^6; sbit SCL = P1^5; void I2C_Init() { // TODO: 初始化 I2C 总线 } void I2C_Start() { SDA = 1; SCL = 1; SDA = 0; SCL = 0; } void I2C_Stop() { SDA = 0; SCL = 1; SDA = 1; } void I2C_WriteByte(unsigned char dat) { unsigned char i; for (i = 0; i < 8; i++) { SDA = dat & 0x80; SCL = 1; SCL = 0; dat <<= 1; } SDA = 1; SCL = 1; SCL = 0; } unsigned char I2C_ReadByte() { unsigned char i, dat = 0; SDA = 1; for (i = 0; i < 8; i++) { SCL = 1; dat <<= 1; dat |= SDA; SCL = 0; } return dat; } void AD5933_ReadImpedance(unsigned char *impedance) { I2C_Start(); I2C_WriteByte((AD5933_I2C_ADDR << 1) | 0); I2C_WriteByte(0x81); I2C_Start(); I2C_WriteByte((AD5933_I2C_ADDR << 1) | 1); impedance[0] = I2C_ReadByte(); impedance[1] = I2C_ReadByte(); I2C_Stop(); } void main() { unsigned char impedance[2]; I2C_Init(); AD5933_ReadImpedance(impedance); // 处理阻抗参数数据 } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值