-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
954 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// DAC.c | ||
// Runs on LM4F120 or TM4C123, | ||
// edX lab 13 | ||
// Implementation of the 4-bit digital to analog converter | ||
// Daniel Valvano, Jonathan Valvano | ||
// March 13, 2014 | ||
// Port B bits 3-0 have the 4-bit DAC | ||
|
||
#include "DAC.h" | ||
#include "..//tm4c123gh6pm.h" | ||
|
||
// **************DAC_Init********************* | ||
// Initialize 4-bit DAC | ||
// Input: none | ||
// Output: none | ||
void DAC_Init(void){ | ||
|
||
} | ||
|
||
|
||
// **************DAC_Out********************* | ||
// output to DAC | ||
// Input: 4-bit data, 0 to 15 | ||
// Output: none | ||
void DAC_Out(unsigned long data){ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// DAC.h | ||
// Runs on LM4F120 or TM4C123, | ||
// edX lab 13 | ||
// Header file for the 4-bit digital to analog converter | ||
// Daniel Valvano, Jonathan Valvano | ||
// March 13, 2014 | ||
|
||
// **************DAC_Init********************* | ||
// Initialize 4-bit DAC | ||
// Input: none | ||
// Output: none | ||
void DAC_Init(void); | ||
|
||
|
||
// **************DAC_Out********************* | ||
// output to DAC | ||
// Input: 4-bit data, 0 to 15 | ||
// Output: none | ||
void DAC_Out(unsigned long data); | ||
|
||
|
||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[EXTDLL] | ||
Count=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Lab13.c | ||
// Runs on LM4F120 or TM4C123 | ||
// Use SysTick interrupts to implement a 4-key digital piano | ||
// edX Lab 13 | ||
// Daniel Valvano, Jonathan Valvano | ||
// March 13, 2014 | ||
// Port B bits 3-0 have the 4-bit DAC | ||
// Port E bits 3-0 have 4 piano keys | ||
|
||
#include "..//tm4c123gh6pm.h" | ||
#include "Sound.h" | ||
#include "Piano.h" | ||
#include "TExaS.h" | ||
|
||
// basic functions defined at end of startup.s | ||
void DisableInterrupts(void); // Disable interrupts | ||
void EnableInterrupts(void); // Enable interrupts | ||
void delay(unsigned long msec); | ||
int main(void){ // Real Lab13 | ||
// for the real board grader to work | ||
// you must connect PD3 to your DAC output | ||
TExaS_Init(SW_PIN_PE3210, DAC_PIN_PB3210,ScopeOn); // activate grader and set system clock to 80 MHz | ||
// PortE used for piano keys, PortB used for DAC | ||
Sound_Init(); // initialize SysTick timer and DAC | ||
Piano_Init(); | ||
EnableInterrupts(); // enable after all initialization are done | ||
while(1){ | ||
// input from keys to select tone | ||
|
||
} | ||
|
||
} | ||
|
||
// Inputs: Number of msec to delay | ||
// Outputs: None | ||
void delay(unsigned long msec){ | ||
unsigned long count; | ||
while(msec > 0 ) { // repeat while there are still delay | ||
count = 16000; // about 1ms | ||
while (count > 0) { | ||
count--; | ||
} // This while loop takes approximately 3 cycles | ||
msec--; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Piano.c | ||
// Runs on LM4F120 or TM4C123, | ||
// edX lab 13 | ||
// There are four keys in the piano | ||
// Daniel Valvano | ||
// September 30, 2013 | ||
|
||
// Port E bits 3-0 have 4 piano keys | ||
|
||
#include "Piano.h" | ||
#include "..//tm4c123gh6pm.h" | ||
|
||
|
||
// **************Piano_Init********************* | ||
// Initialize piano key inputs | ||
// Input: none | ||
// Output: none | ||
void Piano_Init(void){ | ||
|
||
} | ||
// **************Piano_In********************* | ||
// Input from piano key inputs | ||
// Input: none | ||
// Output: 0 to 15 depending on keys | ||
// 0x01 is key 0 pressed, 0x02 is key 1 pressed, | ||
// 0x04 is key 2 pressed, 0x08 is key 3 pressed | ||
unsigned long Piano_In(void){ | ||
|
||
return 0; // remove this, replace with input | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Piano.h | ||
// Runs on LM4F120 or TM4C123, | ||
// edX lab 13 | ||
// There are four keys in the piano | ||
// Daniel Valvano, Jonathan Valvano | ||
// March 13, 2014 | ||
|
||
// **************Piano_Init********************* | ||
// Initialize piano key inputs | ||
// Input: none | ||
// Output: none | ||
void Piano_Init(void); | ||
|
||
|
||
// **************Piano_In********************* | ||
// Input from piano key inputs | ||
// Input: none | ||
// Output: 0 to 15 depending on keys | ||
// 0x01 is key 0 pressed, 0x02 is key 1 pressed, | ||
// 0x04 is key 2 pressed, 0x08 is key 3 pressed | ||
unsigned long Piano_In(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Sound.c | ||
// Runs on LM4F120 or TM4C123, | ||
// edX lab 13 | ||
// Use the SysTick timer to request interrupts at a particular period. | ||
// Daniel Valvano, Jonathan Valvano | ||
// March 13, 2014 | ||
// This routine calls the 4-bit DAC | ||
|
||
#include "Sound.h" | ||
#include "DAC.h" | ||
#include "..//tm4c123gh6pm.h" | ||
|
||
// **************Sound_Init********************* | ||
// Initialize Systick periodic interrupts | ||
// Also calls DAC_Init() to initialize DAC | ||
// Input: none | ||
// Output: none | ||
void Sound_Init(void){ | ||
|
||
} | ||
|
||
// **************Sound_Tone********************* | ||
// Change Systick periodic interrupts to start sound output | ||
// Input: interrupt period | ||
// Units of period are 12.5ns | ||
// Maximum is 2^24-1 | ||
// Minimum is determined by length of ISR | ||
// Output: none | ||
void Sound_Tone(unsigned long period){ | ||
// this routine sets the RELOAD and starts SysTick | ||
} | ||
|
||
|
||
// **************Sound_Off********************* | ||
// stop outputing to DAC | ||
// Output: none | ||
void Sound_Off(void){ | ||
// this routine stops the sound output | ||
} | ||
|
||
|
||
// Interrupt service routine | ||
// Executed every 12.5ns*(period) | ||
void SysTick_Handler(void){ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Sound.h | ||
// Runs on LM4F120 or TM4C123, | ||
// edX lab 13 | ||
// Use the SysTick timer to request interrupts at a particular period. | ||
// Daniel Valvano, Jonathan Valvano | ||
// March 13, 2014 | ||
|
||
// **************Sound_Init********************* | ||
// Initialize Systick periodic interrupts | ||
// Also initializes DAC | ||
// Input: none | ||
// Output: none | ||
void Sound_Init(void); | ||
|
||
// **************Sound_Tone********************* | ||
// Change SysTick periodic interrupts to start sound output | ||
// Input: interrupt period | ||
// Units of period are 12.5ns | ||
// Maximum is 2^24-1 | ||
// Minimum is determined by length of ISR | ||
// Output: none | ||
void Sound_Tone(unsigned long period); | ||
|
||
|
||
// **************Sound_Off********************* | ||
// stop outputing to DAC | ||
// Output: none | ||
void Sound_Off(void); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// TExaS.h | ||
// Runs on LM4F120/TM4C123 | ||
// Periodic timer Timer4A, ADC1, PD3, and UART0 used to create the scope | ||
// Periodic timer Timer5A which will interact with debugger and grade the lab | ||
// It initializes on reset and runs whenever interrupts are enabled | ||
// Jonathan Valvano | ||
// March 4, 2014 | ||
|
||
/* This example accompanies the book | ||
"Embedded Systems: Real Time Operating Systems for ARM Cortex M Microcontrollers", | ||
ISBN: 978-1466468863, Jonathan Valvano, copyright (c) 2013 | ||
Section 6.4.5, Program 6.1 | ||
Copyright 2013 by Jonathan W. Valvano, valvano@mail.utexas.edu | ||
You may use, edit, run or distribute this file | ||
as long as the above copyright notice remains | ||
THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED | ||
OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. | ||
VALVANO SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, | ||
OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. | ||
For more information about my classes, my research, and my books, see | ||
http://users.ece.utexas.edu/~valvano/ | ||
*/ | ||
|
||
// IMPORTANT: These enumerated types are specific to Lab 13. | ||
enum InputPorts{ | ||
SW_PIN_PA5432 = 0, | ||
SW_PIN_PB3210 = 1, | ||
SW_PIN_PE3210 = 4 | ||
}; | ||
|
||
enum OutputPorts{ | ||
DAC_PIN_PA5432 = 0, // optionally, you can use PA7-2, but the top two bits are not graded | ||
DAC_PIN_PB3210 = 1, // optionally, you can use PB5-0, but the top two bits are not graded | ||
DAC_PIN_PE3210 = 4 // optionally, you can use PE5-0, but the top two bits are not graded | ||
}; | ||
|
||
enum ScopeModes{ | ||
ScopeOff = 0, // no scope needed | ||
ScopeOn = 1 // turn on UART0 and stream analog data from PD3 to TExaSdisplay | ||
}; | ||
// ************TExaS_Init***************** | ||
// Initialize grader, triggered by timer 5A | ||
// This needs to be called once | ||
// Inputs: iport input(s) connected to this port | ||
// oport output(s) connected to this port | ||
// scope true if oscilloscope to be implemented (uses UART0 and TExaSdisplay) | ||
// Outputs: none | ||
void TExaS_Init(enum InputPorts iport, enum OutputPorts oport, enum ScopeModes scope); | ||
|
||
// ************TExaS_Stop***************** | ||
// Stop the transfer | ||
// Inputs: none | ||
// Outputs: none | ||
void TExaS_Stop(void); |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.