AnsweredAssumed Answered

STM32F103 hangs when erasing page and receiving USART data

Question asked by passault.gegoire on Mar 11, 2015
Latest reply on Mar 11, 2015 by Clive One

I am currently working on a STM32F103, and I want to program the flash. However, it appear that programming the flash with an USART device receiving bytes in the same time make it hangs:

FLASH_BASE->CR |= FLASH_CR_PER; 
while (FLASH_BASE->SR & FLASH_SR_BSY); 
 
FLASH_BASE->AR = pageAddr; 
FLASH_BASE->CR |= FLASH_CR_STRT; // Hangs forever when receiving 
                                 // data on USART2 in the same time 
while (FLASH_BASE->SR & FLASH_SR_BSY); 
FLASH_BASE->CR &= ~FLASH_CR_PER; 

Disabling the RE flag on USART2 before and re-enabling it after avoids the problem, but it prevent me from receiving data during the operation, which would be possible since the receive interrupt is in the RAM.

Actually, looks like it is not related to the interrupt itself, because it still hangs without the receive interrupt.

Any idea?
Thanks

Outcomes