-
51串口打印不出来,12M晶振!!哪里出问题了!!求看!
晶振12M,波特率设置的2400,打印就不出来,更别提别的数据了。#include#include#includesbitTemp_data=P3^6;voidDHT11_start();unsignedcharDHT11_rec_byte();voidDHT11_receive();voidDHT11_delay_us(unsignedcharn);voidDHT11_delay_ms(unsignedintz);voidInitUART(void);unsignedintrec_dat[4];voidmain(){InitUART();P1=0Xf0;EA=1;while(1){DHT11_delay_ms(150);DHT11_receive();printf("Humi:%d.%d\n",rec_dat[0],rec_dat[1]);printf("Temp:%d.%dC\n",rec_dat[2],rec_dat[3]);}}voidDHT11_start(){Temp_data=1;DHT11_delay_us(2);Temp_data=0;DHT11_delay_ms(20);Temp_data=1;DHT11_delay_us(13);}unsignedcharDHT11_rec_byte(){unsignedchari,dat;for(i=0;i
2022-04-30 5