This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Explain statements in the program blinking leds



Hi all

You to explain his statements in the program blinking leds

#include "lm4f120h5qr.h"

void main(void)
{
long i;
SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;
GPIO_PORTF_DEN_R = 0x08+0x04+0x02;
GPIO_PORTF_DIR_R = 0x08+0x04+0x02;
while(1)
{
GPIO_PORTF_DATA_R=0x02;
for(i=0;i<3000000;i++);
GPIO_PORTF_DATA_R=0x00;
for(i=0;i<5000000;i++);
}
}

Because his new learn lm4f120 should difficult to understand, hope you to explain the above statement 

Thank :)

  • Suspect you question:

    a) GPIO_PORTF_DEN_R = 0x08+0x04+0x02;   enables bits 3, 2, and 1 PortF.   Better to use |= to avoid "disturbance" to other bits

    b) GPIO_PORTF_DIR_R = 0x08+0x04+0x02;   configures same bits as above as outputs.  Again better to use |=

    c) the while loop seems bit strange - again "heavy handed" use of = sets only bit 1, delays, then 2nd "heavy handing" resets all bits.  (&= better)

    Doubt that the single #include you list is adequate for this piece of code to run.  Further review of the original code will assist...