#include "60S2_V3.h"
char bdata bittest ;
sbit TIbit = bittest ^ 0 ;
unsigned long i , sum = 0 , result = 0 , temp , ASC[] , count ;
u8 T_COUNT , adc_hi , adc_low , a , sign ;
void main(void)
{
//AD
ADC_CONTR|=80;
for(i=0;i<10000;i++);
P1ASF = 0x04;
ADC_CONTR=0xE2;
for(i=0;i<10000;i++);
TMOD = 0X11 ;
TH0 = ( 65536 - 50000 ) / 256 ;
TL0 = ( 65536 - 50000 ) % 256 ;
TR0 = 1 ;
ET0 = 1 ;
//串口
SCON = 0X40 ;
BRT = 0XFD ;
AUXR = 0X11 ;
IE2 = 0X01 ;
EA = 1 ;
while(1)
{
//数码管显示
temp = result ;
for ( i = 0 ; i <9; i++ )
{
// SEND7279_CMD_DATA( 0x87 - i , temp % 10) ;
temp = temp / 10 ;
}
}
}
void et0(void) interrupt 1
{
TH0 = ( 65536 - 50000 ) / 256 ;
TL0 = ( 65536 - 50000 ) % 256 ;
T_COUNT ++ ;
ADC_CONTR |= 0x08 ;
sign = 0;
while( sign == 0 )
{
sign = ADC_CONTR & 0X10 ;
}
ADC_CONTR &= 0XE7 ;
adc_hi = ADC_RES & 0x03 ;
adc_low = ADC_RESL ;
sum = sum + ADC_RES * 256 + ADC_RESL ;
if ( T_COUNT == 40 )
{
T_COUNT = 0 ;
result = sum / 40 ;
sum = 0 ;
temp = result ;
while( temp != 0 )
{
a = 0 ;
ASC[a]= temp % 10 + 0x30 ;
temp = temp / 10 ;
a++ ;
}
SBUF = ASC[0] ;
}
}
void UART_ISR() interrupt 4
{
TIbit = 0 ;
SBUF = ASC[count] ;
count++ ;
SCON &= 0XFD ;
}
是个电子秤的软件,单片机STC12C5A60S2,
此帖出自
小平头技术问答
一周热门 更多>