<< Chapter < Page Chapter >> Page >

The ports connected to the LEDs, buttons and buzzer are then initialized.

Finally, the interrupts are activated, and the application waits for the execution of one of two interrupts.

The Basic Timer1 interrupt executes at a frequency of once every second. When this interrupt is occurs, it begins by switching the state of LED1 and LED2. Afterwards, it accesses the memory to fetch the next musical note to be performed. The routine ends with memory pointer management.

The Port 1 ISR begins by evaluating the source of the interrupt. The sound volume is reduced if the button SW1 is pressed. The sound volume is increased if button SW2 is pressed.

System configuration


It is the responsibility of Timer_B to produce the PWM signal that activates the Buzzer. Timer_B counts until the value contained in the TBCCR0 register is reached. It does not generate an interrupt, and must be sourced by SMCLK clock signal:


Each PWM signal produced by Timer_B corresponds to a musical note. The relationship between the frequency and the musical note is given in Table 1.

Freq [Hz] 503 524 587 662 701 787 878 1004 1048

Timer_B has a frequency clock input equal to 7.995392 MHz.

The value to write in the TBCCR0 register in order to generate the desired frequency is:

// TBCCR0 value of the musical notes #define SI0 15895#define DO 15258 #define RE 13620#define MI 12077 #define FA 11405#define SOL 10159 #define LA 9106#define SI 7963 #define DO2 7629TBCCTL4 = OUTMOD_3; // CCR4 interrupt enabledTBCCR4 = space[0]/2;

Timer_a configuration

TACTL = TASSEL_2 |MC_2 | ID_0 | TAIE; // SMCLK, continuous mode up to 0xffff TACCTL1 = CM1 | CCIS_0 | CAP | CCIE;// Capture on rising edge, Cap mode,// Cap/Com int. enable, TACCR1 input signal selected//********************************************************* // Timer A ISR//********************************************************* #pragma vector=TIMERA1_VECTOR__interrupt void TimerA1_ISR (void) {switch (TAIV) {case TAIV_TACCR1: if (capture == 0){T1 = TACCR1; flag = 1;capture = 1; }else { if (flag == 1) {T2 = TACCR1; if (T2>T1) T = T2-T1;} else{TAR = 0; }capture = 0; flag = 0;} break; case TAIV_TACCR2: break;case TAIV_TAIFG:tick++; if (tick == 60){LCD_freq(); tick = 0;} if (flag == 1)flag = 0; break; default: break;} }

Basic timer1

The Basic Timer1 generates an interrupt once every second. It uses two counters in series, where the BTCNT2 counter input uses the BTCNT1 counter output divided by 256. The BTCNT1 counter input is the ACLK clock signal with a frequency of 32.768 kHz.

If BTCNT2 counter selected output is divided by 128, what is the time period associated with the Basic Timer1 interrupt? _________

What are the values to write to the configuration registers?

BTCTL = BTDIV | BT_fCLK2_DIV128; // (ACLK/256)/128 IE2 |= BTIE; // enable BT interrupt//*********************************************************// Basic Timer ISR. Run with 1 sec period //*********************************************************#pragma vector=BASICTIMER_VECTOR __interrupt void basic_timer_ISR(void){ unsigned int read_data; // read data from file , frequency in kHzP2OUT^=0x06; // toogle LED1 and LED2counter++;if (counter == 5){ counter = 0;read_data = 200; TBCCR0 = 7995392/read_data;TBCCR4 = TBCCR0/2; }}

I/o ports configuration

// SW1 and SW2 configuration (Port1) P1SEL&= 0x00; // P1.0 and P1.2 I/O P1DIR&= 0x00; // P1.0 and P1.2 as inputs P1IFG = 0x00;P1IES&= 0xFF // high-to-low transition interrupt P1IE |= 0xFF; // enable port interrupts// LED1 and LED2 configuration (Port2):P2DIR |= 0x06; // P2.2 and P2.1 as outputs P2OUT = 0x04; // LED1 on and LED2 off// Buzzer port configuration (Port3)P3SEL |= 0x20; // P3.5 as special function P3DIR |= 0x20; // P3.5 as digital output

Fll+ configuration

FLL_CTL0 |= DCOPLUS + XCAP18PF; //DCO+ set,freq=xtal*D*N+1 SCFI0 |= FN_4; // x2 DCO freq, 8MHz nominal DCOSCFQCTL = 121; // (121+1) x 32768 x 2 = 7.99 MHz

Analysis of operation

System clocks inspection

The MCLK, SMCLK and ACLK system clocks are available at ports P1.1, P1.4 and P1.5 respectively. These ports are located on the SW2, RESET_CC and VREG_EN lines, which are available on the H2 Header pins 2, 5 and 6. All these resources are available because the Chipcon RF module is not installed and SW2 is not used.

Using the Registers view, set bits 1, 4 and 5 of P1SEL and P1DIR registers to choose the secondary function of their ports, that is, configured as outputs. Connect an oscilloscope probe at these positions to monitor the clock signals.

What are the values measured for each of the system clocks?

ACLK: _____________________

SMCLK: ____________________

MCLK: _____________________

Tbccr4 unit output frequency

With the help of an oscilloscope, it is possible to evaluate the operation of the application. Alternatively, it is possible to listen to the sound produced. By removing jumper JP1 and connecting the oscilloscope to this pin, it is possible to view the PWM signal produced by the microcontroller. The duty-cycle can be reduced or increased by pressing the push buttons SW1 and SW2.

Port p1 interrupt source decoding

All Port P1 interrupt lines share the same interrupt vector. The decoding is done through the P1IFG register.

This process can be observed by entering a breakpoint at the first line of the ISR code.

Execute the application.

The application’s execution is suspended at the breakpoint by pressing either button SW1 or SW2. From this point onwards, run the lines of code step-by-step and observe changes in the register values.

Measurement of electrical current drawn

The power consumption was discussed in the previous point. The electrical power required by the system during operation is measured by replacing the jumper on the Header PWR1 by an ammeter, which indicates the electric current taken by device during operation.

What is the value read? __________

This example and many others are available on the MSP430 Teaching ROM.

Request this ROM, and our other Teaching Materials here (External Link)

Questions & Answers

find the 15th term of the geometric sequince whose first is 18 and last term of 387
Jerwin Reply
The given of f(x=x-2. then what is the value of this f(3) 5f(x+1)
virgelyn Reply
hmm well what is the answer
how do they get the third part x = (32)5/4
kinnecy Reply
can someone help me with some logarithmic and exponential equations.
Jeffrey Reply
sure. what is your question?
okay, so you have 6 raised to the power of 2. what is that part of your answer
I don't understand what the A with approx sign and the boxed x mean
it think it's written 20/(X-6)^2 so it's 20 divided by X-6 squared
I'm not sure why it wrote it the other way
I got X =-6
ok. so take the square root of both sides, now you have plus or minus the square root of 20= x-6
oops. ignore that.
so you not have an equal sign anywhere in the original equation?
is it a question of log
Commplementary angles
Idrissa Reply
im all ears I need to learn
right! what he said ⤴⤴⤴
what is a good calculator for all algebra; would a Casio fx 260 work with all algebra equations? please name the cheapest, thanks.
Kevin Reply
a perfect square v²+2v+_
Dearan Reply
kkk nice
Abdirahman Reply
algebra 2 Inequalities:If equation 2 = 0 it is an open set?
Kim Reply
or infinite solutions?
The answer is neither. The function, 2 = 0 cannot exist. Hence, the function is undefined.
Embra Reply
if |A| not equal to 0 and order of A is n prove that adj (adj A = |A|
Nancy Reply
rolling four fair dice and getting an even number an all four dice
ramon Reply
Kristine 2*2*2=8
Bridget Reply
Differences Between Laspeyres and Paasche Indices
Emedobi Reply
No. 7x -4y is simplified from 4x + (3y + 3x) -7y
Mary Reply
how do you translate this in Algebraic Expressions
linda Reply
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
Crystal Reply
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
Chris Reply
what's the easiest and fastest way to the synthesize AgNP?
Damian Reply
types of nano material
abeetha Reply
I start with an easy one. carbon nanotubes woven into a long filament like a string
many many of nanotubes
what is the k.e before it land
what is the function of carbon nanotubes?
I'm interested in nanotube
what is nanomaterials​ and their applications of sensors.
Ramkumar Reply
what is nano technology
Sravani Reply
what is system testing?
preparation of nanomaterial
Victor Reply
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
Himanshu Reply
good afternoon madam
what is system testing
what is the application of nanotechnology?
In this morden time nanotechnology used in many field . 1-Electronics-manufacturad IC ,RAM,MRAM,solar panel etc 2-Helth and Medical-Nanomedicine,Drug Dilivery for cancer treatment etc 3- Atomobile -MEMS, Coating on car etc. and may other field for details you can check at Google
anybody can imagine what will be happen after 100 years from now in nano tech world
after 100 year this will be not nanotechnology maybe this technology name will be change . maybe aftet 100 year . we work on electron lable practically about its properties and behaviour by the different instruments
name doesn't matter , whatever it will be change... I'm taking about effect on circumstances of the microscopic world
how hard could it be to apply nanotechnology against viral infections such HIV or Ebola?
silver nanoparticles could handle the job?
not now but maybe in future only AgNP maybe any other nanomaterials
I'm interested in Nanotube
this technology will not going on for the long time , so I'm thinking about femtotechnology 10^-15
can nanotechnology change the direction of the face of the world
Prasenjit Reply
At high concentrations (>0.01 M), the relation between absorptivity coefficient and absorbance is no longer linear. This is due to the electrostatic interactions between the quantum dots in close proximity. If the concentration of the solution is high, another effect that is seen is the scattering of light from the large number of quantum dots. This assumption only works at low concentrations of the analyte. Presence of stray light.
Ali Reply
the Beer law works very well for dilute solutions but fails for very high concentrations. why?
bamidele Reply
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Got questions? Join the online conversation and get instant answers!
QuizOver.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Teaching and classroom laboratories based on the “ez430” and "experimenter's board" msp430 microcontroller platforms and code composer essentials. OpenStax CNX. May 19, 2009 Download for free at http://cnx.org/content/col10706/1.3
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Teaching and classroom laboratories based on the “ez430” and "experimenter's board" msp430 microcontroller platforms and code composer essentials' conversation and receive update notifications?