Esempio n. 1
0
// Interrupt service routine
// Executed every 12.5ns*(period)
void SysTick_Handler(void){
	if (isOn == 1) {
		Index = (Index+1)&0x0F;  
		DAC_Out(SineWave[Index]); 
	} else {
		DAC_Out(0);
	}
}
Esempio n. 2
0
interrupt 8 void TC0handler(void){
 TFLG1  = 0x01; 
 
 if(Note != 0){
   DAC_Out(SinTab[index]);
   index++;
 } else{
   DAC_Out(0);
 }
 if(index == 32){
  index = 0;
 }
  TC0 = Wait+TCNT;
  PTP = PTP^0x80;
}
Esempio n. 3
0
// **************Sound_Off*********************
// stop outputing to DAC
// Output: none
void Sound_Off(void){
 // this routine stops the sound output
	
	NVIC_ST_RELOAD_R = 0; // clear reload value
	NVIC_ST_CTRL_R = 0;
	DAC_Out(0);
}
Esempio n. 4
0
// Interrupt service routine
// Executed every 12.5ns*(period)
void SysTick_Handler(void) {
    //GPIO_PORTF_DATA_R ^= 0x08;     // toggle PF3, debugging
    Index = (Index+1)&0x1F;
    if (off != 1) {
        DAC_Out(wave[Index]);
    }
}
Esempio n. 5
0
// Reads the next sine point needed to be output to the DAC
void Next_Sine_Point(void){
  //short nextPoint = Volume_Adjust(Horn[Current_Sine_Point],Vol);
  
  //DAC_Out(nextPoint);
  DAC_Out(Horn[Current_Sine_Point]);
  Current_Sine_Point = (Current_Sine_Point+1)&0x1F;
}
Esempio n. 6
0
void Music_Play(const unsigned short *instrument, int instrumentSize, const struct Songs* song, int songSize){
		int noteIndex=0;
		int i=0;
		int pause=0;	
	
	while(1){
		if(play){
			pause=1-pause;
			resetSwitches();
		}
		if(rewind||mode){
			break;
		}
		if(lenPush&&!pause){
			Timer0A_Init(song->duration[noteIndex]);
			SysTick_Init(402000/(song->notes[noteIndex]));
			noteIndex=(noteIndex+1)%songSize;
		}
		if(notePush&&!pause){
			notePush=0;
			DAC_Out(instrument[i]);
			i=(i+1)%instrumentSize;
		}
	}

	/*
	//in class he mentioned something about having to layer two interrupts ontop of each other and how that can help, we may 
	//have to do something with that. I plan on asking the TA's about it tomorrow.
		DAC_Out(song->notes[Time&0x1F] + instrument[Time&0x1F]);
	//	DAC_Out(song->notes[Time&0x1F]);
	//	DAC_Out(instrument[Time&0x1F]);
    Time = Time + 1;
		SysTick_Wait(song->duration[Time&0x1F]);
	*/
}
Esempio n. 7
0
void SysTick_Handler(void) {
	GPIO_PORTG2 ^= 0x04;        // toggle PD0
	DAC_Out(sinArray[index]);
	index+=1;
	if (index >= SAMPLE_RATE) {
		index = 0;
	}
}
Esempio n. 8
0
void Timer2A_Handler(void){
  TIMER2_ICR_R = 0x00000001;   // acknowledge timer2A timeout
	DAC_Out(sound[TimerCount]);
	if(TimerCount < 1837){
			TimerCount++;}
	else{Timer2A_Stop();}
			
}
Esempio n. 9
0
void Timer1A_Handler(void){
	TIMER1_ICR_R = TIMER_ICR_TATOCINT;// acknowledge TIMER1A timeout
  // (*PeriodicTask1)();                // execute user task

	if(Index==length){
		Sound_Play (Centipede_Beat, 1304);
	}
	DAC_Out(array[Index]);
	Index++;
}
int main(void){
  n = 0;
  TExaS_Init(SW_PIN_PA5432, DAC_PIN_PB3210,SCOPE); // activate grader 
  DAC_Init();   // your code to initialize the DAC
  EnableInterrupts();
  while(1){
    DAC_Out(n);     // your code to output to the DAC
    delay(1000); // wait 1s (later change this to 1ms)
    n = (n+1)&0x0F;
  }
}
// **************Sound_Play*********************
// Start sound output, and set Systick interrupt period 
// Input: interrupt period
//           Units to be determined by YOU
//           Maximum to be determined by YOU
//           Minimum to be determined by YOU
//         input of zero disable sound output
// Output: none
void Sound_Play(uint32_t period){
	NVIC_ST_RELOAD_R = period-1;																// reload value
	extern uint32_t waveIndex;
	extern const uint8_t wave[32];
	
	DAC_Out(wave[waveIndex]);
	waveIndex = 0x1F&(waveIndex+1);
	
	
	
}
Esempio n. 12
0
void Timer3A_Handler(void) {
    TIMER3_ICR_R = TIMER_ICR_TATOCINT;// acknowledge TIMER1A timeout
    if (!testish) {
        testish = 1;
        TIMER3_TAILR_R = 0xFFFFFFFF;
    }
    if (play == 1) {
        DAC_Out(SinWave[count]);
        count = (count + 1) & 0x01F;
    }
}
Esempio n. 13
0
//Timer A: Interrupts on Frequency
//**This method needs to be fixed
void Timer0A_Handler(void){
	
  TIMER0_ICR_R = TIMER_ICR_TATOCINT;// acknowledge timer0A timeout
		
	//this is broken:
	//if(++Count%wave_freq != 0){
	//	return;
	//}
	
	DAC_Out(1024); //0, 512, 
	wave_loc = (wave_loc + 1) % 32;
}
Esempio n. 14
0
/*
 * Funcion principal
 */
int main(void) {
	// Configuracion del reloj a 40MHz
	SysCtlClockSet(SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ | SYSCTL_USE_PLL | SYSCTL_SYSDIV_5);

	// Configurar la interfaz SSI
	SSI0_Init();

	while (1) {
		// Enviar un dato
		DAC_Out(100);
		SysCtlDelay(26666666);
		DAC_Out(500);
		SysCtlDelay(26666666);
		DAC_Out(1000);
		SysCtlDelay(26666666);
		DAC_Out(2000);
		SysCtlDelay(26666666);
		SSIDataPutNonBlocking(SSI0_BASE, 2500);
		SysCtlDelay(26666666);
	}
}
Esempio n. 15
0
void Timer2A_Handler(void){static unsigned long i= 0;
  TIMER2_ICR_R = 0x00000001;   // acknowledge timer2A timeout
	
	//output to DAC
	DAC_Out(anysound[i]);
	i = (i+1)%Sound_Count;
	if(i==0){
		Timer2A_Stop();
	}
//other conter stuff
  TimerCount++;
}
Esempio n. 16
0
void Timer1A_Handler(void) {
    TIMER1_ICR_R = 0x00000001;   	// acknowledge timer1A timeout
    if (playSound == 1) {
        if (soundIndex < 982) {
            DAC_Out(fastinvader1[soundIndex]);
            soundIndex ++;
        }
        else {
            soundIndex = 0;
            playSound = 0;
        }
    }
}
//****************Timer1A_Handler***************
//Plays different sound effects depending on the *sound
//Input: none
//Output: none
void Timer1A_Handler(void){
	TIMER1_ICR_R = TIMER_ICR_TATOCINT;// acknowledge TIMER1A timeout
	TIMER0_CTL_R = 0x0000000;    //disable TIMER0A
	TIMER2_CTL_R = 0x0000000;    //disable TIMER2
  if(SoundCount > 0){ 
    //GPIO_PORTB_DATA_R = CurrSound[SoundIndex]>>4; // DAC out
		DAC_Out(CurrSound[SoundIndex]);
    SoundIndex += 1;
    SoundCount -= 1;
		
//		DAC_Out(CurrSound[Index]);    // output one value each interrupt
//	if((Index+ 1) == 0x20) 	{Index= 0; }
//	Index = (Index+1);//&0x1F;      // 8,9,11,12,13,14,14,15,15,15,14,14,13,12,11,9,8,7,... 
  }
	else // If sound ends, disable timer0 & stop sound
		{TIMER0_CTL_R = 0x0000001;    //enable TIMER0A
		TIMER2_CTL_R = 0x0000001;    //enable TIMER2
		TIMER1_CTL_R = 0x00000000;}

	TIMER0_CTL_R = 0x0000001;    //enable TIMER0A
	TIMER2_CTL_R = 0x0000001;    //enable TIMER2
}
Esempio n. 18
0
void
OnTick(void) {
  waveIndex = (waveIndex + 1) & 0x0F;

  DAC_Out(isSoundEnabled ? SineWave[waveIndex] : 0);
}
Esempio n. 19
0
// Interrupt service routine
// Executed every 12.5ns*(period)
void SysTick_Handler(void){
  GPIO_PORTF_DATA_R ^= 0x0F;     // 
  Index = (Index+1)&0x1F;  
  DAC_Out(SineWave[Index]); 
}
Esempio n. 20
0
// Interrupt service routine
// Executed every 12.5ns*(period)
void SysTick_Handler(void){
  Index = (Index+1)&0x1F;
  DAC_Out(SineWave[Index]);    // output one value each interrupt   
}
// **************Sound_Off*********************
// stop outputing to DAC
// Output: none
void Sound_Off(void){
	soundOff = 1;
	DAC_Out(0);
}
// Interrupt service routine
// Executed every 12.5ns*(period)
void SysTick_Handler(void){
	if(!soundOff){
		DAC_Out(SineWave[indx]);
		indx = (indx + 1) % 64;
	}
}
void SysTick_Handler(void){
	
	DAC_Out(SineCurrSound[Index]);    // output one value each interrupt
	Index = (Index+1)&0x3F;      // 8,9,11,12,13,14,14,15,15,15,14,14,13,12,11,9,8,7,... 
}
Esempio n. 24
0
void Music_Play(const unsigned short *instrument, int instrumentSize, const struct Songs* song, int songSize){
		int noteIndex=0;
		int i=0;
		int pause=0;	
		const unsigned short *testInstr;
		testInstr = &Flute[0];
		
	while(1){
		if(play){
			plotImage();
			pause=1-pause;
			resetSwitches();
		}
		if(aNote){
			plotImage();
			demoPtr->notes[noteIndex] = 1776;
			demoPtr->duration[noteIndex] = 10000;
			lenPush = 1;
			aNote = 0;
		}
		if(fNote){
			plotImage();
			demoPtr->notes[noteIndex] = 2237;
			demoPtr->duration[noteIndex] = 10000;
			lenPush = 1;	
			fNote = 0;
		}
		if(bNote){
			plotImage();
			demoPtr->notes[noteIndex] = 1582;
			demoPtr->duration[noteIndex] = 10000;
			lenPush = 1;
			bNote = 0;
		}
		if(eNote){
			plotImage();
			demoPtr->notes[noteIndex] = 2370;
			lenPush = 1;
			eNote = 0;
		}
		
		if(lenPush&&!pause){
			Timer0A_Init(demoPtr->duration[noteIndex]);
			//SysTick_Init(402000/(song->notes[noteIndex]));
			//SysTick_Init(402000/(furElisePtr->notes[noteIndex]));
			SysTick_Init(402000/(demoPtr->notes[noteIndex]));
			//SysTick_Init(402000/(demo1Ptr->notes[noteIndex])); 			
			noteIndex=(noteIndex+1)%(songSize);
		}
		if(notePush&&!pause){
			notePush=0;
			DAC_Out(instrument[i]);
			i=(i+1)%instrumentSize;
		}
	}

	/*
	//in class he mentioned something about having to layer two interrupts ontop of each other and how that can help, we may 
	//have to do something with that. I plan on asking the TA's about it tomorrow.
		DAC_Out(song->notes[Time&0x1F] + instrument[Time&0x1F]);
	//	DAC_Out(song->notes[Time&0x1F]);
	//	DAC_Out(instrument[Time&0x1F]);
    Time = Time + 1;
		SysTick_Wait(song->duration[Time&0x1F]);
	*/
}
Esempio n. 25
0
// Interrupt service routine
// Executed every 12.5ns*(period)
void SysTick_Handler(void){
	Index = (Index+1)&0x1F;			// index to cycle over sin wave (0x1F would cycle over the 32 table)
	DAC_Out(SineWave[Index]);		// output the sine wave value to DAC
}