stc89c52很多有用程序(STC89C52 a lot of useful programs)
Function: AD0832 driver read analog voltage value, convert AD
After the value of the use of serial output. CHO of ADC0832
(channel 0) is the voltage change detection of photosensitive resistance.
At the same time, increase the digital display AD conversion value function.
Serial output, serial debugging is a microcontroller program
The monly used and most important tool. Need to be used before use
The development board crystal oscillator frequency is , such as
No, please replace the crystal, or self timer calculation
Numerical value.
Time: 2011-8-23
******************************************/
/ / header file
#include <>
#include <>
/ / macro definition
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
/ / pin definition
Sbit ADC0832_CLK = P3^5;
Sbit ADC0832_DODI =P2^7;
Sbit ADC0832_CS = P3^4;
/*****************************************************/
(according to the definition of pin / / hardware changes)
Sbit BCD6 = P1^5;
Sbit BCD5 = P1^4;
Sbit BCD4 = P1^3;
Sbit BCD3 = P1^2;
Sbit BCD2 = P1^1;
Sbit BCD1 = P1^0;
#define BCD_PORT P0
/**********************************************************************************************/
Code uchar BCD[]={0x3f, 0x06,0x5b, 0x4f, 0x66,0x6d, 0x7d, 0x07,0x7f, 0x6f, 0xbf, 0x86,0xdb, 0xcf, 0xe6,0xed, 0xfd, 0x87,0xff, 0xef, 0x40};
/ / definition digital display array as a constant, common cathode
1. / / /*0,1,2,3,4,5,6,7,8,9,0., 2., 3., 4., 5., 6., 7., 8., 9., - /
/ / function declaration
/******************************************/
/ / delay functions when,
The parameters of d_time control / / delay time
Effect of light extinction and / /, must persist for some time, the human eye can see
Void delay (unsigned int time);
/******************************************/
/ / delay functions
The range of parameters of 0-65536 / /
Void delay (unsigned int time) / time size parameters
{/ / det
stc89c52很多有用程序(STC89C52 a lot of useful programs) 来自淘豆网www.taodocs.com转载请标明出处.