2017-12-04 09:21 AM
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 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));
withwhile(TC1==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 ..
#flag-check #bitband #while #stuck Note: this post was migrated and contained many threaded conversations, some content may be missing.Solved! Go to Solution.
2017-12-07 04:22 AM
Define the 'Cross Post' ! ??
A topic on the same http address and domain ? or even different ? Please stay out of the topics if you really don't want to contribute !
2017-12-07 04:24 AM
While(Flag) vs While(REG->FLAG & 1u<12); You think ?
2017-12-07 04:30 AM
Yes, a 'Cross-Post' is posting the same question in multiple places.
It is considered impolite because you end up wasting people's time as they give an answer in one place, unaware that someone else has already given the same answer elsewhere.
If you are going to cross-post, then always give links between the posts, and be sure that you keep monitoring all locations!
2017-12-07 04:34 AM
I prefer using constants defined in the CMSIS-mandated device headers instead of numeric constants, to mask/set SFR bits.
JW
2017-12-07 05:01 AM
What if a person is not a member of ST community but a member of ARM community alone ? A forum search on ARM is not going to redirect you to STM since it is not a GOOGLE ... You speak as if somebody has to surf on STM forum .. NO THEY DO NOT ... And secondly I like different ideas coming from different people ...
It is you who wastes people's time .. So I will not argue with you anylonger ...
2017-12-07 05:04 AM
Could you please give a simple example ? And second of all thank you for your first answer that saves from drowning inside the code I never thought volatile may work in such a powerful way .. Maybe It is because I just have never read the language and it is uses completely ..
2017-12-07 05:20 AM
Like I said, you should make it clear that you are cross-posting, and include links.
Then everyone can follow the entire conversation if they wish
2017-12-07 05:25 AM
Sharing links may or may not be reliable for everyone ... So it is not a 'should' ... It is a 'may' .. I choose not to ...
2017-12-07 05:35 AM
Remember that you're the one asking people to help you - for free.
2017-12-07 05:37 AM
Just see how far you get with your attitude.