I think I know the answer of the thread title's question, but let me explain why I'm asking it anyway.
I'm taking the Edx course Embedded Systems - Shape The World: Microcontroller Input/output. In one of the lectures there's a code fragment that's confusing me a lot. Here's the important part of that code:
#include "tm4c123ge6pm.h" // Subroutine to initialize port F pins for input and output // PF4 is input and PF2 is output void PortF_Init(void) { volatile unsigned long delay; SYSCTL_RCGC2_R |= 0x00000020; // 1) activate clock for Port F delay = SYSCTL_RCGC2_R; // allow time for clock to start GPIO_PORTF_LOCK_R = 0x4C4F434B; // 2) unlock GPIO Port F GPIO_PORTF_CR_R = 0x1F; // allow changes to PF4-0 // only PF0 needs to be unlocked, other bits can't be locked GPIO_PORTF_AMSEL_R = 0x00; // 3) disable analog on PF GPIO_PORTF_PCTL_R = 0x00000000; // 4) PCTL GPIO on PF4-0 GPIO_PORTF_DIR_R = 0x0E; // 5) PF4,PF0 in, PF3-1 out GPIO_PORTF_AFSEL_R = 0x00; // 6) disable alt funct on PF7-0 GPIO_PORTF_PUR_R = 0x11; // enable pull-up on PF0 and PF4 GPIO_PORTF_DEN_R = 0x1F; // 7) enable digital I/O on PF4-0 }
What bothers me here is line #10. I know what is the purpose of that line of code. But why it was written that way? Is that some kind of idiomatic way of waiting in TI's microcontrollers code?
In ISSUE#2 of Diagnosing Common Development Problems and Tips & Info for TM4C Devices the same problem is solved with a much clearer code.
Please don't take my question as criticism to the authors of the code. I'm just really confused.
r