2014. február 4., kedd

ARM Course 4. - Comments to the Lab 7

The Lab 7 is not about the coding, but about understanding and modifying code written by others.
I read the original and found this:

  //S
  GPIO_PORTF_DATA_R |= 0x08;  delay(1);
  GPIO_PORTF_DATA_R &= ~0x08; delay(1);
  GPIO_PORTF_DATA_R |= 0x08;  delay(1);
  GPIO_PORTF_DATA_R &= ~0x08; delay(1);
  GPIO_PORTF_DATA_R |= 0x08;  delay(1);
  GPIO_PORTF_DATA_R &= ~0x08; delay(1);
  //O
  GPIO_PORTF_DATA_R |= 0x08; delay(4);
  GPIO_PORTF_DATA_R &= ~0x08;delay(4);
  GPIO_PORTF_DATA_R |= 0x08; delay(4);
  GPIO_PORTF_DATA_R &= ~0x08;delay(4);
  GPIO_PORTF_DATA_R |= 0x08; delay(4);
  GPIO_PORTF_DATA_R &= ~0x08;delay(4);
  //S
  GPIO_PORTF_DATA_R |= 0x08; delay(1);
  GPIO_PORTF_DATA_R &= ~0x08;delay(1);
  GPIO_PORTF_DATA_R |= 0x08; delay(1);
  GPIO_PORTF_DATA_R &= ~0x08;delay(1);
  GPIO_PORTF_DATA_R |= 0x08; delay(1);
  GPIO_PORTF_DATA_R &= ~0x08;delay(1);
  delay(10); // Delay for 5 secs in between flashes


Come on! Are you certain? Professionals write code like this? Tell me, this is a joke, not?
At least this. And this barely good enough:

    char i;
    char j;
    char delays[3] = {1,4,1};
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            GPIO_PORTF_DATA_R |= 0x08;
            delay(delays[i]);
            GPIO_PORTF_DATA_R &= ~0x08;
            delay(delays[i]);
        }
    }
    delay(10);

Do not panic. This is not the solution just the rewriting of the code above.
And this is the end of the 7th module. And what's next?
The 8th module is nowhere. To be precise "under development":
http://users.ece.utexas.edu/~valvano/Volume1/E-Book/



Nincsenek megjegyzések:

Megjegyzés küldése