Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Writ a chunk of code for the TM4C board that does the following Essentially take

ID: 3851105 • Letter: W

Question

Writ a chunk of code for the TM4C board that does the following

Essentially take the program we did for lab 2 and modify it so that the frequency that the light cycle goes through changes when a button is pressed. Have it start from 1Hz and for each button press have it increase by 1Hz until 10Hz, at which start over from 1Hz.

Lab 2 code below:

#include <tm4c123gh6pm.h>
int main()
{
int i,j;

       SYSCTL->RCGCGPIO |= 0x20;
       SYSCTL->RCGCTIMER |= 0x02;
   for(i = 0; i < 1000; i++);
   GPIOF->DEN = 0xFF;
   GPIOF->DIR = 0x0E;
   TIMER1->CFG = 0x00;
TIMER1->TAMR = 0x02;
   TIMER1->TAILR = 32000000;
   TIMER1->CTL = 0x01;
   j = TIMER1->TAILR;
   while(1)
   {
       GPIOF->DATA &= 0xF1;
       i = TIMER1->TAV;
       if ((0 < i) && (i<j/3))
           GPIOF->DATA |=0x02;
       else if ((j/3 < i) && (i < 2*j/3))
           GPIOF->DATA |= 0x04;
       else
           GPIOF->DATA |= 0x08;
   }
   return 0;
}

Explanation / Answer

#include <tm4c123gh6pm.h>
int main()
{
int i,j;

       SYSCTL->RCGCGPIO |= 0x20;
       SYSCTL->RCGCTIMER |= 0x02;
   for(i = 0; i < 1000; i++);
   GPIOF->DEN = 0xFF;
   GPIOF->DIR = 0x0E;
   TIMER1->CFG = 0x00;
TIMER1->TAMR = 0x02;
   TIMER1->TAILR = 32000000;
   TIMER1->CTL = 0x01;
   j = TIMER1->TAILR;
   while(1)
   {
       GPIOF->DATA &= 0xF1;
       i = TIMER1->TAV;
       if ((0 < i) && (i<j/3))
           GPIOF->DATA |=0x02;
       else if ((j/3 < i) && (i < 2*j/3))
           GPIOF->DATA |= 0x04;
       else
           GPIOF->DATA |= 0x08;
   }
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote