AnsweredAssumed Answered

While loop stucks

Question asked by Burak Günay on Dec 4, 2017
Latest reply on Dec 7, 2017 by AvaTar

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 ...

TC1 is defined as USART1_SR_TC register bitband alias ...

#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
      while(!(USART1->SR&USART_SR_TC));// Transmit Complete ?


When I replace




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 ..