Answered step by step
Verified Expert Solution
Question
1 Approved Answer
answer in code composer, using MSP432P401R microcontroller, using C language 2. Given 25 notes of the musical scale below: They are each produced by a
answer in code composer, using MSP432P401R microcontroller, using C language
2. Given 25 notes of the musical scale below: They are each produced by a square wave with frequency as defined by the following formula: fnote=4402P/12wherePrangesfrom12(lowALA)to12(highAHA) The period of the square wave is illustrated in figure 1 below. Figure 1: Equations for Period and 1/2 Period of a note square wave When the system clock is initialized to 48MHz the subsystem clock (SMCLK) is 12MHz, or a quarter of the system clock. This will be too fast for the purpose of this lab. When the system clock is not initialized to 48MHz using the Clocklnit_48MHz() function, it defaults to 3MHz and SMCLK also defaults to 3MHz. You can verify your board is not dividing the clock by reviewing the registers for the clock system here: If your MSP432 defaults to a divide by 4 SMCLK then use 750kHz for the calculations below. Clock cycle in 1/2Tnote=2fnote13MHz1=2fnote3MHz=(TAxCCRn+1) - For the 25 notes (f foue =220 through fnote=880 ) determine the TA0CCR1 values needed to output the square wave of each note using TimerA0 in Reset/Set mode. Hint: write a program to do the math for you and print the results to the console using printfo. - Open another program and use \#define to create 25 constants for the results of part 1. Also create time delay constants (explained in the reading music section below) - In the initialization section of main setup TimerA to create a square wave. - Create a function called playNote( a. It takes in an integer representing the max count for a given note and assigns that value to the TAOCCR0 register. b. Use the same max count divided by two to configure the TA0CCR1 register. c. The function also takes in a delay constant to hold the note a given amount of time. d. The function must then disable TimerA and delay a short amount of time to put a break between notes. Try about 50ms. e. Use the SysTick timer to delay between notes. Remember that SysTick is 24 bits and uses the system clock - In the main loop call the function with different notes and delays in between. You can look up simple songs on the intemet and experiment with the delays to actually play a song. See the example on the following pages. - Use the speaker from your lab kit and drive one pin with the waveform output and the other to ground. Look at the bottom to see positive and negative pins. - YOU MAY NOT USE MARY HAD A LITTLE LAMB FOR YOUR ASSIGNMENT. This is only provided as an example Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started