This laboratory implements a new task to generate a dual-tone using the speaker on the LM3S1968 evaluation board. Your GTA will assign additional parts of this exercise.
To begin this lab, make a copy of the Program_Blinky project in your workspace.
Select the Program_Blinky project and right-click.
In the workspace pane, right-click and select “Paste”
When asked for a project name, use the project name “Program_SpeakerBuzz”
Within the new project, rename “Program_Blinky.c” to “Program_Speakerbuzz.c” and “Program_Blinky_startup.c” to “Program_Speakerbuzz_startup.c”
1.1 Improve SysTick Coding
Verify the following changes have been made in your “Program_SpeakerBuzz.c” code.
The value of “SysTickFrequency_Nbr” variable should be 10000. This will set the SysTick period to 0.1 milliseconds. Your define statement should look like:
extern uint32_t SysTickFrequency_Nbr = 10000;
1.2 Tone Generation Task
Write a new task with necessary state variables and functions named “Task_Speakerbuzz.c”. Follow the pattern in “Task_Blinky.c”.
Add a call to “Task_Speakerbuzz.c” in your main program.
1.2.1 Initialize GPIO PortH
You must initialize GPIOH bits <1..0> to drive the speaker. Your GTA will give you a frequency for the tone you need to generate and that will determine the SpeakerBuzz delta interval. Here is example set-up code:
Enable the GPIO Port H.
EECS 388 Laboratory #2
SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOH );
Configure GPIO_H to drive the Speaker.
GPIO_PIN_1 | GPIO_PIN_0 );
GPIO_PIN_1 | GPIO_PIN_0,
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );
Set PortH<0> ON and PortH<1> OFF.
GPIO_PIN_1 | GPIO_PIN_0, 0x01 );
Determine the delta execute time based on the frequency your GTA gave you. Schedule the next execution time equal to the current “SysTickCount_Nbr” value and the delta execute time. Set the state of the task to initialized.
1.2.2 Toggle the Speaker GPIO Bits
When time to execute, you should toggle GPIOH bits <1:0> similar to toggling the LED bit in Task0_Execute() (BlinkExecute()).
Read the GPIOH bits.
Toggle bits <1..0> with an XOR operator
Write the GPIOH bits <1..0> with the new value.
Set a new next execution time.
1.2.3 Laboratory Measurements
Your GTA will ask you to measure the frequency of your “Task_SpeakerBuzz” using an oscilloscope. Make sure you can checkout equipment from the EECS shop.
1.3 Dual-Tone SpeakerBuzz
Write a new task based on your SpeakerBuzz task that alternates between the two tones holding each tone for 750 mS. Your GTA will assign a second tone to implement.
EECS 388 Laboratory #2