单片机小BAI..。
求.路.大.,STC8H单片机打印ADC采集电压输出为0,以下图一是STC官网下载的程序
#include "stc8h.h"
#include "intrins.h"
#define FOSC 11059200UL
#define BRT (65536 - FOSC / 115200 / 4)
#define USBCHIPID
#define CPUIDBASE 0xfde0
#define VREF_ADDR (*(unsigned int volatile xdata *)(CPUIDBASE + 0x07))
bit busy;
void UartIsr() interrupt 4
{
if (TI)
{
TI = 0;
busy = 0;
}
if (RI)
{
RI = 0;
}
}
void UartInit()
{
SCON = 0x50;
TMOD = 0x00;
TL1 = BRT;
TH1 = BRT >> 8;
TR1 = 1;
AUXR = 0x40;
busy = 0;
}
void UartSend(char dat)
{
while (busy);
busy = 1;
SBUF = dat;
}
void ADCInit()
{
P_SW2 |= 0x80;
ADCTIM = 0x3f;
P_SW2 &= 0x7f;
ADCCFG = 0x2f;
ADC_CONTR = 0x8f;
}
void ADC()
{
P_SW2 |= 0x80;
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
UartInit();
ES = 1;
EA = 1;
UartSend(VREF_ADDR >> 8);
UartSend(VREF_ADDR);
}
#include "reg51.h"
#include "intrins.h"
#include <stdio.H>
#include <adc.H>
void main(){
ADCInit();
UartInit();
ADC();
while(1)
{
printf("%d\r\n",VREF_ADDR);
}
}
#ifndef __ADC8H_H__
#define __ADC8H_H__
ADCInit();
UartInit();
ADC();
int VREF_ADDR;