Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
vielex
/
bes_labs_2019
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
65fba1fc
authored
Mar 12, 2019
by
Víctor Elexpe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First steps
parent
ffba0b05
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
Labware/Lab9_FunctionalDebugging/main.c
Labware/Lab9_FunctionalDebugging/main.c
View file @
65fba1fc
...
...
@@ -11,6 +11,7 @@
// ***** 1. Pre-processor Directives Section *****
#include "TExaS.h"
#include "tm4c123gh6pm.h"
#include <stdbool.h>
// ***** 2. Global Declarations Section *****
...
...
@@ -25,16 +26,21 @@ void EnableInterrupts(void); // Enable interrupts
/*
This Lab9 starter project is the same as C9_Debugging example but
includes the connections to the Lab9 grader. You will make three changes.
First, make the LED flash at 10 Hz. In other words, make it turn on for 0.05 seconds,
and then turn off for 0.05 seconds.
Second, make the LED flash if either switch SW1 or SW2 is pressed
(this means flash the LED if either PF4 or PF0 is 0).
Third, record PortF bits 4,1,0 every time the input changes or the output changes.
For example, if your system detects a change in either PF4 or PF0 input,
record PortF bits 4,1,0. If your system causes a change in PF1, record PortF bits 4,1,0.
If both PF4 and PF0 switch are not pressed, the PF1 output should be low.
If either PF4 or PF0 switches is pressed, the output toggles at 10 Hz (±10%).
If either PF4 or PF0 switches is pressed, the output toggles at 10 Hz (�10%).
Information collected in the Data array matches the I/O on PortF.
50 data points are collected only on a change in input or a change in output.
This means no adjacent elements in the array should be equal.
...
...
@@ -65,7 +71,7 @@ void SysTick_Init(void){
}
unsigned
long
Led
;
void
Delay
(
void
){
unsigned
long
volatile
time
;
time
=
160000
;
// 0.1
sec
time
=
80000
;
// 0.05
sec
while
(
time
){
time
--
;
}
...
...
@@ -75,16 +81,26 @@ unsigned long Time[50];
// you must leave the Data array defined exactly as it is
unsigned
long
Data
[
50
];
int
main
(
void
){
unsigned
long
i
,
last
,
now
;
bool
changed
;
TExaS_Init
(
SW_PIN_PF40
,
LED_PIN_PF1
);
// activate grader and set system clock to 16 MHz
PortF_Init
();
// initialize PF1 to output
SysTick_Init
();
// initialize SysTick, runs at 16 MHz
i
=
0
;
// array index
changed
=
false
;
last
=
NVIC_ST_CURRENT_R
;
EnableInterrupts
();
// enable interrupts for the grader
while
(
1
){
if
(
!
(
GPIO_PORTF_DATA_R
&
0x01
)
||
!
(
GPIO_PORTF_DATA_R
&
0x10
)){
// PF0 or PF4
Led
=
GPIO_PORTF_DATA_R
;
// read previous
Led
=
Led
^
0x02
;
// toggle red LED
GPIO_PORTF_DATA_R
=
Led
;
// output
changed
=
true
;
}
else
{
//disable LED if nothing is pressed
GPIO_PORTF_DATA_R
&=~
0x02
;
}
if
(
i
<
50
){
now
=
NVIC_ST_CURRENT_R
;
Time
[
i
]
=
(
last
-
now
)
&
0x00FFFFFF
;
// 24-bit time difference
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment