在线时间0 小时
UID315428
ST金币0
蝴蝶豆0
注册时间2011-8-29
新手上路
- 最后登录
- 1970-1-1
|
a0a.1 0b0c
这是我的初始化函数,但是之后调用USART_SendData(USART6, (u8)(printf_buf)),用示波器看串口的TX没有数据发出去,也用串口调试助手试过,都没有数据,这是怎么回事?请大家看看,我用的是STM32F207的mcu
void Printf_Init(void)
{
#ifdef __DEBUG_PRINT
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
USART_ClockInitTypeDef USART_ClockInitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);
GPIO_PinAFConfig(GPIOC,GPIO_PinSource6,GPIO_AF_USART6);
GPIO_PinAFConfig(GPIOC,GPIO_PinSource7,GPIO_AF_USART6) ;
GPIO_InitStructure.GPIO_Pin = GPIO_PinSource7;
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_ResetBits(GPIOC, GPIO_PinSource6);
GPIO_InitStructure.GPIO_Pin = GPIO_PinSource6;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_Init(GPIOC, &GPIO_InitStructure);
USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low;
USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge;
USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable;
USART_ClockInitStructure.USART_Clock = USART_Clock_Disable;
USART_ClockInit(USART6, &USART_ClockInitStructure);
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_Mode = USART_Mode_Tx;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(USART6, &USART_InitStructure);
USART_Cmd(USART6, ENABLE); //enable USART6
#ifdef STM32_PRINT_USE_DMA
/* enable DMA clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE);
#endif
#endif
} |
|