Hello ..
I am having a very weird issue with my code piece .. The MCU is STM32F407VET6 .. What I'm trying to do is sending a string via USART1 peripheral module .. In order check if the character in the USART1 is sent out of the USART1->DR register I am continuously checking the "Transmit Complete Bit of the usart1 status register The code below works well ...
#define TC1 *((uint32_t *)(0x42220018)) //Previously defined at //the top of the main file void EXTI4_IRQHandler(void) { uint8_t i; char x[6]="BURAK\n"; EXTI_PR_Bit4=1; // Cleared by writing 1 // ISR code TC1=0; for(i=0;i<7;i++) { USART1->DR=x[i]; while(!(USART1->SR&USART_SR_TC));// Transmit Complete ? } TC1=0; }
BUT !
When I replace
while(!(USART1->SR&USART_SR_TC));
with
while(TC==0);
The code stucks.. freezes ... and stops ...Why does it happen ?? Are Bit-Band Aliases not reliable things to use with while ,if , for statements ?? Does it have to be read/modify/write sequence always ??
Thanks in advance ..