qq_42451281
爱喝姜壮奶
2019-04-20 18:52

甲醛传感器ZE08与ZIGbee串口调试是否有冲突?

  • c语言

1.甲醛传感器(主动上传模式)直接接在51上可以LCD可以显示正常值串口可以收到传感器的值且值正常,但在中间接上一个ZIGbee模块(只要有VCC跟TX同时接上!!!)单片机与串口调试都不能接收到传感器的值,ZIGbee模块也不工作。

2.直接在能用的CH340上进行串口调试也没有任何数据(ZE08为主动上传模式)。

附上51代码如下:


#include<reg52.h>
#include<intrins.h>
#include"delay.h"
#include"1602.h"

#define uchar unsigned char
#define uint unsigned int

uchar code table[]={"0123456789"};
uchar UART_Upload[9];  
uint ppb_h,ch2o,ch2o_m;
uchar accord;
void init()
{
    ppb_h=0;
}
void init_ser()
{
    SCON=0x50;       
    TMOD=0x20;       
    PCON=0x00;     
    TH1=0xfd;   //
    TL1=0xfd;       //波特率:9600  11.0592MHz 

    TR1=1;

    TI=0;
    RI=0;   
    EA=1; 
    ES=1;      
}
void main()
{
    LCD_Init();
    delayms(5);
    LCD_Clear();
    delayms(5);
    init_ser();
    init();
    while(1)
    {
        LCD_Write_String(0,0,"CH2O:");
        LCD_Write_String(9,0,"ppb");
        LCD_Write_String(11,1,"mg/m3");
        LCD_Write_String(6,1,".");

        LCD_Write_Char(5,0,table[ch2o/1000]);
        LCD_Write_Char(6,0,table[ch2o%1000/100]);
        LCD_Write_Char(7,0,table[ch2o%100/10]);
        LCD_Write_Char(8,0,table[ch2o%10]);

        LCD_Write_Char(5,1,table[ch2o_m/10000]);
        LCD_Write_Char(7,1,table[ch2o_m%10000/1000]);
        LCD_Write_Char(8,1,table[ch2o_m%1000/100]);
        LCD_Write_Char(9,1,table[ch2o_m%100/10]);
        LCD_Write_Char(10,1,table[ch2o%10]);
    }
}
void serial () interrupt 4 
{
    uchar temp_ppb;
    if(RI==1)
    {
        RI=0;
        UART_Upload[accord]=SBUF; 
        accord++;
        if(accord>8)        
        {
            accord=0;
        }       
        if(accord==0)       
        {                    
            temp_ppb=~(UART_Upload[1]+UART_Upload[2]+UART_Upload[3]+UART_Upload[4]+UART_Upload[5]+UART_Upload[6]+UART_Upload[7])+1; //检验和
            if(temp_ppb==UART_Upload[8])
            {
                ch2o=UART_Upload[4]*256+UART_Upload[5];
                ch2o_m=ch2o*13.392857;
            }       
        }

    }
}

请教大神们有啥解决办法?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换