cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F302R8 MCU UART2 Tx Incompleted

Scott Shan
Associate II
Posted on November 10, 2017 at 05:42

Hi,

I used STM32F103 MCU before and was new for STM32F3x MCU. My stm32f103 codes was migrated to stm32f302 codes for stm32f302r8 MCU.The code problem is that after power on, MCU turned on LED normally and printed out ''0123456789'' only (full string should be '1234567890'), and then got stuck. Attached please find my stm32f302 codes. Can anyone expert help me to fix this issue? Thanks in advance.

0690X0000060PCNQA2.png

2 REPLIES 2
Posted on November 10, 2017 at 18:00

Use TXE to determine the DR is EMPTY before stuffing data, don't use TC for that purpose.

/*********************************************************************

* @brief Print character for USART

*/

void USART_PrintChar(USART_TypeDef* USARTx, u8 ch)

{

while (USART_GetFlagStatus(USARTx, USART_FLAG_TXE) == RESET); // empty, ready for new data

USARTx->TDR = ch; //USARTx->DR = ch;

}

/*********************************************************************

* @brief Print string for USART

*/

void USART_PrintStr(USART_TypeDef* USARTx, char *str)

{

while(*str)

USART_PrintChar(USARTx, *str++);

while (USART_GetFlagStatus(USARTx, USART_FLAG_TC) == RESET); // Wait complete if must

}

/*********************************************************************

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Scott Shan
Associate II
Posted on November 11, 2017 at 10:39

Many Thanks for the replay.

I found the major issue is inside routine '

NVIC_Configuration()'.

=================================

void NVIC_Configuration(void)

{

NVIC_InitTypeDef NVIC_InitStructure;

NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x6000); 

<== I uploaded firmware which started from memory 0x00 (without bootloader), so should remove this line.

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

....

}

=================================