This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Keil -O0 and -O1 optimize

My code

while(usart_transmit_status);
usart_transmit_status = 1;

translate at -O0

0x08001EB4 4807      LDR      r0,[pc,#28]  ; @0x08001ED4
0x08001EB6 7800      LDRB     r0,[r0,#0x00]
0x08001EB8 2800      CMP      r0,#0x00
0x08001EBA D1FB      BNE      0x08001EB4

and translate at -O1

0x08001A6E 4907      LDR      r1,[pc,#28]  ; @0x08001A8C
0x08001A70 7808      LDRB     r0,[r1,#0x00]
0x08001A72 2800      CMP      r0,#0x00
0x08001A74 D1FD      BNE      0x08001A72

It leads to an error because R0 changes in interruption