Professional Documents
Culture Documents
h>
#include <msp430.h>
#define notas 25
#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 7629
#define MUTE 0
//******************************************************************
// Global data
//******************************************************************
//unsigned int scale[notas] = {SI0, DO, RE, MI, FA, SOL, LA, SI, DO2, MUTE};
unsigned int space[notas] =
{DO,RE,MI,DO,MI,DO,RE,MI,FA,MI,RE,FA,MI,FA,SOL,MI,SOL,MI,SOL,FA,SOL,LA,SOL,FA,LA};
unsigned int index_notas = 0;
char volume = 2;
//******************************************************************
// Port1 Interrupt Service Routine
//******************************************************************
#pragma vector=PORT1_VECTOR
__interrupt void Port_1 (void)
{
if (P1IFG & 0x01) volume = volume - 1;
if (P1IFG & 0x02) volume = volume + 1;
if (volume == 6) volume = 5;
if (volume == 0) volume = 1;
TBCCR4 = space[index_notas]/volume;
// TimerB configuration
TBCCR0 = space[0]; // load first tone from
sequency
TBR = 0; // reset TBR
// SMCLK
// 16-bit, TBR(max) = 0FFFFh
// Each TBCLx latch loads independently
// Up mode: the timer counts up to TBCCR0
// Input divider. These bits select the divider for the input clock.(/1)
TBCTL = 0x210;
// output mode set/reset
TBCCTL4 = 0x60;
TBCCR4 = space[0]/2;
// Interrupts enabled
__enable_interrupt();
while(1);
}