Other Parts Discussed in Thread: EK-TM4C123GXL
Hi,
I am using the TM4C123G launch pad and the Keil development software.
At startup, just after setting the system clock and initializing GPIO Port F, I execute the following loop:
//Wait on SW1 or SW2 to go low
do {
swData = GPIO_PORTF_DATA_R & 0x11;
}
while (swData == 0x11);
if ((swData & 0x01) == 0){
What I am observing is that with a 40 MHz clock, it works as expected. But with an 80MHz clock it eventually will exit the while loop and if I break on the if statement, swData will be set to 0x11. If I insert a short delay in the loop, it will also work fine at 80MHz. I tried it on two separate launchpads so it it not broken HW. Is there a known race condition on this chip that I am running into or am I making some noob mistake?
Thanks in advance
Joe Carbone
PS: Here is the assembly code Keil created
185: //Wait on SW1 or SW2 to go low
0x00000BD0 1D08 ADDS r0,r1,#4
0x00000BD2 6800 LDR r0,[r0,#0x00]
0x00000BD4 F4204070 BIC r0,r0,#0xF000
0x00000BD8 1D09 ADDS r1,r1,#4
0x00000BDA 6008 STR r0,[r1,#0x00]
186: do {
0x00000BDC BF00 NOP
187: swData = GPIO_PORTF_DATA_R & 0x11;
188: }
0x00000BDE 487E LDR r0,[pc,#504] ; @0x00000DD8
0x00000BE0 1F00 SUBS r0,r0,#4
0x00000BE2 6800 LDR r0,[r0,#0x00]
0x00000BE4 F0000011 AND r0,r0,#0x11
0x00000BE8 4984 LDR r1,[pc,#528] ; @0x00000DFC
0x00000BEA 6008 STR r0,[r1,#0x00]
189: while (swData == 0x11);
190:
191: //SW2 => Record
0x00000BEC 4608 MOV r0,r1
0x00000BEE 6800 LDR r0,[r0,#0x00]
0x00000BF0 2811 CMP r0,#0x11
0x00000BF2 D0F4 BEQ 0x00000BDE