佚名通过本文主要向大家介绍了stm32f103串口例程,stm32f103串口下载,stm32f103串口通信,stm32f103c8t6串口,stm32f103rbt6串口等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: stm32f103串口接收字符串的奇怪问题求教
描述:

2.通过APP控制WIFI板块串口输出“ONA”,“ONB”,“ONF”,MINI板接收,控制电平转换以控制电机正转,反转,停止
现在问题是程序烧好了,发送端(WIFI串口输出)也没问题了,但是不知道程序问题出在哪?
3.附上程序:
#include "stm32f10x_lib.h"
#include "stdio.h"
#include "stm32f10x_it.h"
void RCC_Configuration(void);
void GPIO_Configuration(void);
void NVIC_Configuration(void);
void USART_Configuration(void);
void delay_nms(u16 time);
void TIM4_Configuration(void);
void SendCom_Juge(void);
void TIM3_Configuration(void);
char instruct[5],j;
u8 Recv_Comp;
u16 Rev=4000;//转速
/*******************************************************************************
* 函数名 : main
* 函数描述 : Main 函数
*******************************************************************************/
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
NVIC_Configuration();
USART_Configuration();
TIM4_Configuration();
TIM3_Configuration();
while(1)
{
delay_nms(30);
SendCom_Juge();
}
}
void delay_nms(u16 time)
{
u16 i=0;
while(time--)
{
i=12000; //自己定义
while(i--) ;
}
}
/*******************************************************************************
* 函数名 : NVIC_Configuration
*******************************************************************************/
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
#ifdef VECT_TAB_RAM
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);/* Set the Vector Table base location at 0x20000000 */
#else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQChannel ; //通道设置为串口1中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //中断占先等级0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //中断响应优先级0,赋予高的优先级
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //打开中断
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQChannel; /*TIM3中断*/
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; /*先占优先级0级*/
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; /*从优先级3级*/
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; /*IRQ通道被使能*/
NVIC_Init(&NVIC_InitStructure);
}
/*******************************************************************************
* 函数名 : USART_Configuration
*******************************************************************************/
void USART_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 9600;
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(USART2 , &USART_InitStructure);
USART_Cmd(USART2 , ENABLE);
USART_ITConfig(USART2,USART_IT_RXNE,ENABLE); //一定要开启串口接收中断
USART_ClearFlag(USART2,USART_FLAG_TC); //发送完成标志位
}
/*******************************************************************************
* 函数名 : RCC_Configuration
* 函数描述 : 设置系统各部分时钟
*******************************************************************************/
void RCC_Configuration(void)
{
ErrorStatus HSEStartUpStatus; /* 定义枚举类型变量 HSEStartUpStatus */
RCC_DeInit(); /* 复位系统时钟设置*/
RCC_HSEConfig(RCC_HSE_ON); &nbs
描述:
STM32stm32串口
1.WIFI板块+秉火STM32MINI板
2.通过APP控制WIFI板块串口输出“ONA”,“ONB”,“ONF”,MINI板接收,控制电平转换以控制电机正转,反转,停止
现在问题是程序烧好了,发送端(WIFI串口输出)也没问题了,但是不知道程序问题出在哪?
3.附上程序:
#include "stm32f10x_lib.h"
#include "stdio.h"
#include "stm32f10x_it.h"
void RCC_Configuration(void);
void GPIO_Configuration(void);
void NVIC_Configuration(void);
void USART_Configuration(void);
void delay_nms(u16 time);
void TIM4_Configuration(void);
void SendCom_Juge(void);
void TIM3_Configuration(void);
char instruct[5],j;
u8 Recv_Comp;
u16 Rev=4000;//转速
/*******************************************************************************
* 函数名 : main
* 函数描述 : Main 函数
*******************************************************************************/
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
NVIC_Configuration();
USART_Configuration();
TIM4_Configuration();
TIM3_Configuration();
while(1)
{
delay_nms(30);
SendCom_Juge();
}
}
void delay_nms(u16 time)
{
u16 i=0;
while(time--)
{
i=12000; //自己定义
while(i--) ;
}
}
/*******************************************************************************
* 函数名 : NVIC_Configuration
*******************************************************************************/
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
#ifdef VECT_TAB_RAM
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);/* Set the Vector Table base location at 0x20000000 */
#else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQChannel ; //通道设置为串口1中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //中断占先等级0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //中断响应优先级0,赋予高的优先级
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //打开中断
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQChannel; /*TIM3中断*/
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; /*先占优先级0级*/
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; /*从优先级3级*/
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; /*IRQ通道被使能*/
NVIC_Init(&NVIC_InitStructure);
}
/*******************************************************************************
* 函数名 : USART_Configuration
*******************************************************************************/
void USART_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 9600;
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(USART2 , &USART_InitStructure);
USART_Cmd(USART2 , ENABLE);
USART_ITConfig(USART2,USART_IT_RXNE,ENABLE); //一定要开启串口接收中断
USART_ClearFlag(USART2,USART_FLAG_TC); //发送完成标志位
}
/*******************************************************************************
* 函数名 : RCC_Configuration
* 函数描述 : 设置系统各部分时钟
*******************************************************************************/
void RCC_Configuration(void)
{
ErrorStatus HSEStartUpStatus; /* 定义枚举类型变量 HSEStartUpStatus */
RCC_DeInit(); /* 复位系统时钟设置*/
RCC_HSEConfig(RCC_HSE_ON); &nbs