Laboratory Exercise #2 SpeakerBuzz Solution

$28.20

Quantity

You'll get a: . zip file solution : immediately, after Payment

Offer ends in

Description

Rate this product

1 Introduction

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.

  1. Select the Program_Blinky project and right-click.

  1. Select “Copy”

  1. In the workspace pane, right-click and select “Paste”

  1. When asked for a project name, use the project name “Program_SpeakerBuzz”

  1. 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.

  1. 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

1

Version B

SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOH );

//

  • Configure GPIO_H to drive the Speaker.

GPIOPinTypeGPIOOutput( GPIO_PORTH_BASE,

GPIO_PIN_1 | GPIO_PIN_0 );

GPIOPadConfigSet( GPIO_PORTH_BASE,

GPIO_PIN_1 | GPIO_PIN_0,

GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD );

//

  • Set PortH<0> ON and PortH<1> OFF.

GPIOPinWrite( GPIO_PORTH_BASE,

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()).

  1. Read the GPIOH bits.

  1. Toggle bits <1..0> with an XOR operator

  1. Write the GPIOH bits <1..0> with the new value.

  1. 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

2

Version B

0