找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1393|回复: 2
打印 上一主题 下一主题
收起左侧

STM32控制HMI串口屏发送指令字符串后,串口屏无响应温度没有改变

[复制链接]
跳转到指定楼层
楼主
5黑币
#include "stm32f10x.h"
#include "usart.h"
#include "delay.h"
#include "mlx90614.h"
#include "sys.h"

extern uint8_t aRxBuffer[100];
extern uint8_t aRxCounter;
extern uint8_t aReceiveState;

void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_USART_ALL_PERIPH(USARTx));
  assert_param(IS_FUNCTIONAL_STATE(NewState));

  if (NewState != DISABLE)
  {
    /* Enable the Half-Duplex mode by setting the HDSEL bit in the CR3 register */
    USARTx->CR3 |= CR3_HDSEL_Set;
  }
  else
  {
    /* Disable the Half-Duplex mode by clearing the HDSEL bit in the CR3 register */
    USARTx->CR3 &= CR3_HDSEL_Reset;
  }
}


volatile uint8_t aRxBuffer[100]={0x00};
volatile uint8_t aRxCounter=0;
volatile uint8_t aReceiveState=0;
int main(void)
{        

  USART_Config();
//DEBUG_USARTx = USART1;
//        DEBUG_USARTx = USART2;
Temperature = SMBus_ReadTemp();
        delay_ms(500);
    while(1)
        {        
               
                                        Temperature = SMBus_ReadTemp();
        
// ′®¿ú1μÄêy¾Y

               
                if(aReceiveState==1)//èç1û½óêÕμ½1Ö¡êy¾Y
                        
                {
                        aReceiveState=0;

                        
                        if(aRxBuffer[0]=='a')
                        {

                          if(aRxBuffer[2]=='1')
                          { x=1;        }
                          else if(aRxBuffer[2]=='2')
                          { x=0;  }

                   }
                }
                                if(x==1)
                {
                        DEBUG_USARTx = USART1;
                        printf("x0.val=%d",(int)(Temperature*10));   //x0.val=%d为向串口屏发送的指令
                        delay_ms(500);
                        usart_pm_end();
                        if(x==2)
                {
                        DEBUG_USARTx = USART1;
                        printf("x0.val=a10");    ////x0.val=%d为向串口屏发送的指令
                }
                }

B547E2CBD10FFDFDE66CFA7827CF0A8B.jpg (1.17 MB, 下载次数: 68)

B547E2CBD10FFDFDE66CFA7827CF0A8B.jpg
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:36656 发表于 2020-10-12 15:43 | 只看该作者
               if(x==1)
                {
                        DEBUG_USARTx = USART1;
                        printf("x0.val=%d",(int)(Temperature*10));   //x0.val=%d为向串口屏发送的指令
                        usart_pm_end();
                        delay_ms(500);
                        if(x==2)
                {
                        DEBUG_USARTx = USART1;
                        //printf("x0.val=a10");    ////x0.val=%d为向串口屏发送的指令
                }
                }
回复

使用道具 举报

板凳
ID:36656 发表于 2020-10-12 15:45 | 只看该作者
用串口调试助手看下你单片机发送的数据是什么
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表