I try to get data from stm32f407vg ,but stm32f407vg can not send any data.
/************************************************************************************/
My configuration settings are here, I try to get data via PB6(pin source 6)
/************************************************************************************/
void GPIO_Config()
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);//USART1
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);//USART3
GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1);//TX
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF ;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 ;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP ;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz ;
GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_USART3);//TX
GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_USART3);//RX
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF ;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP ;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz ;
GPIO_Init(GPIOC, &GPIO_InitStruct);
}
void USART_Config()
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
USART_InitStruct.USART_BaudRate = 9600 ;
USART_InitStruct.USART_WordLength = USART_WordLength_8b;
USART_InitStruct.USART_StopBits = USART_StopBits_1 ;
USART_InitStruct.USART_Parity = USART_Parity_No ;
USART_InitStruct.USART_Mode = USART_Mode_Tx ;
USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(USART1, &USART_InitStruct);
USART_Cmd(USART1, ENABLE);
USART_InitStruct.USART_BaudRate = 115200 ;
USART_InitStruct.USART_WordLength = USART_WordLength_8b ;
USART_InitStruct.USART_StopBits = USART_StopBits_1 ;
USART_InitStruct.USART_Parity = USART_Parity_No ;
USART_InitStruct.USART_Mode = USART_Mode_Tx | USART_Mode_Rx ;
USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(USART3, &USART_InitStruct);
USART_Cmd(USART3, ENABLE);
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
}
void NVIC_Config()
{
NVIC_InitStruct.NVIC_IRQChannel = USART3_IRQn ;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0 ;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0 ;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE ;
NVIC_Init(&NVIC_InitStruct);
}
/************************************************************************************/
/It stucks at the mark/
/************************************************************************************/
void USART_Puts(USART_TypeDef* USARTx, volatile char *s)
{
while(*s)
{
while(!(USARTx -> SR & 0x00000040));//Bit 6 TC: Transmission Complete //<---IT IS STUCK
USART_SendData(USARTx, *s);
*s++;
}
}
/************************************************************************************/
I could not solve what the problem is..
/************************************************************************************/
Could you help me?
testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
User contributions licensed under CC BY-SA 3.0