h>
#define notas 10
#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] = {RE, MI, DO2, DO, SOL, MUTE, MUTE, MUTE, MUTE, MUTE};
unsigned int index_notas = 0;
char volume = 2;
//******************************************************************
// Port1 Interrupt Service Routine
//******************************************************************
#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR (void)
{
if (P1IFG & 0x01) volume = volume - 3;
if (P1IFG & 0x02) volume = volume + 3;
if (volume == 6) volume = 5;
if (volume == 0) volume = 1;
TBCCR4 = space[index_notas]/volume;
P1IFG = 0x00;
}
//*****************************************************************
// Basic Timer Interrupt Service Routine. Run with 1 sec period
//*****************************************************************
#pragma vector=BASICTIMER_VECTOR
__interrupt void basic_timer_ISR(void)
{
// Toogle LED1 and LED2
P2OUT ^= 0x02;
// get next note
TBCCR0 = space[index_notas];
// set duty-cycle
TBCCR4 = space[index_notas]/volume;