Access over 35 million academic & study documents

3 Given the following program #include lm3s1968”#define GPIO P

Content type
User Generated
Showing Page:
1/3
3. Given the following program.
#include lm3s1968
#define GPIO_PORTG_DATA_R (*((volatile unsigned long
*) 0x400263FC))
#define GPIO_PORTG_DIR_R (*((volatile unsigned long *)
0x40026400))
#define GPIO_PORTG_AFSEL_R (*((volatile unsigned long
*) 0x40026420))
#define GPIO_PORTG_DEN_R (*((volatile unsigned long *)
0x4000451C))
#define PG2 (*((volatile unsigned long *) ))
int main(void) {
SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOG; //
activate port G
GPIO_PORTG_DIR_R |= 0x04;
GPIO_PORTG_AFSEL_R &= ~0x04;
GPIO_PORTG_DEN_R |= 0x04;
GPIO_PORTG_DATA_R |= 0x04;
while(1) }
a. Explain all the instructions in the program
b. What does the program do as a whole?
c. Modify the program to use bit banding (just write the
instructions that you will add/modify)
d. Modify the program so that you can manipulate pin 0 of
port G as well
e. While (1) in the above program was replaced with the
following instructions. Explain what the program would do
if we implement the addition (4 points).
while(1) {
PG2 ^= 0x04; }
f. What does the program do now.
g. Calculate the Frequency of the signal generated by the
program
h. Write the assembly equivalence of this instruction:
GPIO_PORTG_DATA_R |= 0x04;

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/3
Solution
#include lm3s1968
#define GPIO_PORTG_DATA_R (*((volatile unsigned long
*) 0x400263FC))
#define GPIO_PORTG_DIR_R (*((volatile unsigned long *)
0x40026400))
#define GPIO_PORTG_AFSEL_R (*((volatile unsigned long
*) 0x40026420))
#define GPIO_PORTG_DEN_R (*((volatile unsigned long *)
0x4000451C))
#define PG2 (*((volatile unsigned long *) ))
int main(void) {
SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOG; //
activate port G
GPIO_PORTG_DIR_R |= 0x04;
GPIO_PORTG_AFSEL_R &= ~0x04;
GPIO_PORTG_DEN_R |= 0x04;
GPIO_PORTG_DATA_R |= 0x04;
while(1) }
a. Explain all the instructions in the program

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/3

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
3. Given the following program. #include “lm3s1968” #define GPIO_PORTG_DATA_R (*((volatile unsigned long *) 0x400263FC)) #define GPIO_PORTG_DIR_R (*((volatile unsigned long *) 0x40026400)) #define GPIO_PORTG_AFSEL_R (*((volatile unsigned long *) 0x40026420)) #define GPIO_PORTG_DEN_R (*((volatile unsigned long *) 0x4000451C)) #define PG2 (*((volatile unsigned long *) )) int main(void) { SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOG; // activate port G GPIO_PORTG_DIR_R |= 0x04; GPIO_PORTG_AFSEL_R &= ~0x04; GPIO_PORTG_DEN_R |= 0x04; GPIO_PORTG_DATA_R |= 0x04; while(1) } a. Explain all the instructions in the program b. What does the program do as a whole? c. Modify the program to use bit banding (just write the instructions that you will add/modify) d. Modify the program so that you can manipulate pin 0 of port G as well e. While (1) in the above program was replaced with the following instructi ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Similar Documents