Question

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

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;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#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;
}

Add a comment
Know the answer?
Add Answer to:
Writ a chunk of code for the TM4C board that does the following Essentially take the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please modify the following code to NOT have "TicTacToe extends Board" (I don't want any extending)....

    Please modify the following code to NOT have "TicTacToe extends Board" (I don't want any extending). Please ensure the resulting code completes EACH part of the following prompt: "Your task is to create a game of Tic-Tac-Toe using a 2-Dimensional String array as the game board. Start by creating a Board class that holds the array. The constructor should use a traditional for-loop to fill the array with "blank" Strings (eg. "-"). You may want to include other instance data......

  • Implement a rabin_hash method to make the following code work: int rabin_karp_batchmatch(int bsz, /* size of...

    Implement a rabin_hash method to make the following code work: int rabin_karp_batchmatch(int bsz, /* size of bitmap (in bits) to be used */ int k, /* chunk length to be matched */ const char *qs, /* query docoument (X)*/ int m, /* query document length */ const char *ts, /* to-be-matched document (Y) */ int n /* to-be-matched document length*/) { /*if the to-be-matched document is less than k length, return false*/ if (n < k) return 0; /*start our...

  • composed the following java code to read a string from a text file but receiving compiling...

    composed the following java code to read a string from a text file but receiving compiling errors. The text file is MyNumData.txt. Included the original java script that generated the output file. Shown also in the required output results after running the java program. I can't seem to search for the string and output the results. Any assistance will be greatly appreciated. import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; public class Main {   public static void main(String[] args) {     System.out.print("Enter the...

  • On the following code there is an error bc you are not reverting back to the...

    On the following code there is an error bc you are not reverting back to the original order after a sort. For the next sort you are passing the same reference variable to the next method. But that will point to the same (already sorted) array on the memory. Hence after the first sorting method, all three sorting methods are working on the already sorted array. Do the following : Just copy each data set to 4 different arrays -...

  • Design a way of using the pushbutton to trigger an interrupt to your system. Your system,...

    Design a way of using the pushbutton to trigger an interrupt to your system. Your system, upon receiving this interrupt, responds by reading and displaying the temperature in Fahrenheit degrees on the LCD display in the format of xxx.x. The system must resume displaying the digital clock. Build your circuit and include all the required information about your hardware design in your lab report. 4. Based on the hardware you designed, choose an interrupt/timer tool from mbed to update the...

  • Java BlackJack Game: Help with 1-4 using the provided code below Source code for Project3.java: import...

    Java BlackJack Game: Help with 1-4 using the provided code below Source code for Project3.java: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class Project3 extends JFrame implements ActionListener { private static int winxpos = 0, winypos = 0; // place window here private JButton exitButton, hitButton, stayButton, dealButton, newGameButton; private CardList theDeck = null; private JPanel northPanel; private MyPanel centerPanel; private static JFrame myFrame = null; private CardList playerHand = new CardList(0); private CardList dealerHand = new CardList(0);...

  • Growing Plant program following guidelines Drawing Canvas Code: import java.awt.Canvas; import java.awt.*; import java.awt.geom.*; /** *...

    Growing Plant program following guidelines Drawing Canvas Code: import java.awt.Canvas; import java.awt.*; import java.awt.geom.*; /** * */ /** */ public class DrawingCanvas extends Canvas { protected String drawString; protected double angleIncrement; DrawingCanvas() { this.setPreferredSize(new Dimension(400, 400)); } public void setDrawString(String s) { drawString = s; } public void setAngleIncrement(double d) { angleIncrement = Math.PI * d/ 180.0; } /** * Paint routine for our canvas. The upper Left hand corner * is 0, 0 and the lower right hand corner...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT