用32的串口发送指令给GY-MCU90615 模块,然后通过串口回传温度,GY-MCU90615 模块的主要用法如下,检查了很多遍,但本应该回传的帧的头格式数据都收不到,下面时我的主函数,求大神帮我看看,卡了好长时间了io口的配置是看例程的,前辈们帮忙看看,没准聪明的你们一眼就看出了问题
#include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "lcd.h"
u8* rebuff[9];
void USART1_IRQHandler(void)
{
int i;
if(USART_GetITStatus(USART1,USART_IT_RXNE))//如果收到数据
for(i=0;i<9;i++)
*rebuff=USART_ReceiveData( USART1);//读数据
// USART_FLAG_RXNE=0;//清除标志位
}
void send_commend(unsigned char com)//发送字节命令
{
if(USART_GetFlagStatus( USART1, USART_FLAG_RXNE)==0)
{
USART_SendData(USART1, com);
}
}
int main(void)
{
u8 times=0;
delay_init(); //延时函数初始化
NVIC_Configuration();// 设置中断优先级分组
uart_init(9600); //串口初始化为9600
LED_Init(); //初始化与LED连接的硬件接口
LCD_Init();USART_SendData
POINT_COLOR=RED;
(USART1, 0xA5);
USART_SendData(USART1, 0xAE);
USART_SendData(USART1, 0x53);//配置波特率为9600;
while(1)
{
times++;
USART_SendData(USART1, 0xA5);
USART_SendData(USART1, 0x45);
USART_SendData(USART1, 0xEA);
LCD_ShowString(30,40,200,24,24,rebuff[0]);
if(times%30==0)LED0=!LED0;//闪烁LED,提示系统正在运行.
delay_ms(10);
}
}
/USART 3õê¼»ˉéèÖÃ
USART_InitStructure.USART_BaudRate = bound;//
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;//
USART_InitStructure.USART_Parity = USART_Parity_No;//
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //
USART_Init(USART1, &USART_InitStructure); //
USART_ITConfig(USART1, USART_IT_RXNE , ENABLE);//开启中断
USART_Cmd(USART1, ENABLE); //ê1Äü′®¿ú
void USART1_IRQHandler(void)
{
if(USART_GetITStatus(USART1,USART_IT_RXNE))//èç1ûêÕμ½êy¾Y
*rebuff[i]=USART_ReceiveData( USART1);//读数据
i++;
if(i==8)
{
i=0;
sign=1;//一帧数据接收完毕标志
}
}
void send_commend(unsigned char com)//发送一个字节命令
{
USART_SendData(USART1, com);
//while(!USART_SR_TC );
//μè′y·¢Ëííê3é
// USART_SR_TC=0;
}
int main(void)
{
u8 times=0;
sign=0;
delay_init(); //Ñóê±oˉêy3õê¼»ˉ
NVIC_Configuration();// éèÖÃÖD¶ÏóÅÏ輶·Ö×é
uart_init(115200); //′®¿ú3õê¼»ˉÎa115200
LED_Init(); //3õê¼»ˉóëLEDᬽóμÄó2¼t½ó¿ú
LCD_Init();
POINT_COLOR=RED;
LCD_Clear(GREEN);
USART_SendData(USART1, 0xA5);
USART_SendData(USART1, 0x45);
USART_SendData(USART1, 0xEA);
while(1)
{
times++;
if(sign)
{
LCD_ShowString(30,40,200,24,24,rebuff[0]+'0');
LED1=~LED1;
}
if(times%30==0)LED0=!LED0;//提示系统正在运行
delay_ms(10);
}
}
一周热门 更多>