STM32/STM8技术论坛
直播中

Mr_RMS

7年用户 327经验值
擅长:可编程逻辑 嵌入式技术 处理器/DSP 接口/总线/驱动 控制/MCU
私信 关注
[问答]

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

程序如下,作用是通过重映射USART3到GPIO10,10管脚,实现串口输出:编译通过,但是,程序数据从串口出不来,用丁丁sscom33串口调试助手一打开就显示:串口被占用或者其他错误,
#include "STM32f10x.h"
#include
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);
}

已退回10积分

回帖(1)

Mr_RMS

2017-4-11 15:27:24
Lz刚开始学,什么都不懂啊,开发板除了用Jlink与电脑连接,其他的还需要连接吗?串口US232怎么连呢?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分