微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > STM32F107VC 串口调试失败,求帮帮看看是不是程序的问题

STM32F107VC 串口调试失败,求帮帮看看是不是程序的问题

时间:10-02 整理:3721RD 点击:
程序如下,作用是通过重映射USART3到GPIO10,10管脚,实现串口输出:编译通过,但是,程序数据从串口出不来,用丁丁sscom33串口调试助手一打开就显示:串口被占用或者其他错误,
#include "stm32f10x.h"
#include <stdio.h>
void RCC_Configuration(void);
void GPIO_Configuration(void);
void USART_Configuration(void);
void delay(__IO uint32_t nCount)
{
  for (; nCount != 0; nCount--);
}
/* Private functions ---------------------------------------------------------*/
/**
  * @brief  Main program.
  * @param  None
  * @retval None
------------------------------------------------------------------------------*/
int main(void)
{
u8 i;
u8 t[]={"I LOVE XIAO"};
RCC_Configuration();
USART_Configuration();
GPIO_Configuration();
GPIO_PinRemapConfig(GPIO_PartialRemap_USART3,ENABLE);
for(i=0;i<8;i++)
{
  USART_SendData(USART3,t[i]);
  delay(800000);
}
}
void RCC_Configuration(void)
{

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);  
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
}
void USART_Configuration()
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_Init(USART3,&USART_InitStructure);
USART_Cmd(USART3,ENABLE);
}
void GPIO_Configuration()
{
GPIO_InitTypeDef GPIO_InitStructure;
/*Configure GPIOC.10 as USART3_Tx*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC,&GPIO_InitStructure);
/*Configure GPIOC.11 as USART3_Rx*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC,&GPIO_InitStructure);
}

Lz刚开始学,什么都不懂啊,开发板除了用Jlink与电脑连接,其他的还需要连接吗?串口US232怎么连呢?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top