int main(void){ // for the real board grader to work, you must connect PD3 to your DAC output int piano; // to read current piano keys int prevPiano; // to store piano keys in prev cycle TExaS_Init(SW_PIN_PE3210, DAC_PIN_PB3210,ScopeOn); // activate grader and set system clock to 80 MHz Sound_Init(); // initialize SysTick timer and DAC Piano_Init(); EnableInterrupts(); // enable after all initialization are done while(1){ piano = Piano_In(); if(piano != prevPiano){ // only react if piano keys pressed if(piano == 0x00) Sound_Off(); else if(piano == 0x01) Sound_Tone(2389); else if(piano == 0x02) Sound_Tone(2128); else if(piano == 0x04) Sound_Tone(1896); else if(piano == 0x08) Sound_Tone(1594); delay(10); } prevPiano = piano; } }
int main(void){ TExaS_Init(SW_PIN_PE3210,DAC_PIN_PB3210,ScopeOn); // bus clock at 80 MHz //Timer0A_Init(&songTask, F80HZ); Piano_Init(); Sound_Init(0); DAC_Init(); Heartbeat_Init(); // other initialization EnableInterrupts(); uint32_t input; while(1){ GPIO_PORTF_DATA_R ^= 0x04; input = Piano_In(); if (input == 0x04){ Sound_Play(A); } else if (input == 0x02){ Sound_Play(C); } else if (input == 0x01){ Sound_Play(Eb); } else if (input == 0x07){ Sound_Play(A); } else { Sound_Play(0); } } }
int main(void){ // Real Lab13 // for the real board grader to work // you must connect PD3 to your DAC output TExaS_Init(SW_PIN_PE3210, DAC_PIN_PB3210,ScopeOn); // activate grader and set system clock to 80 MHz // PortE used for piano keys, PortB used for DAC Sound_Init(); // initialize SysTick timer and DAC Piano_Init(); EnableInterrupts(); // enable after all initialization are done DAC_Init(); while(1){ volatile unsigned long current_switch; current_switch = Piano_In(); if (current_switch == 0x01){ EnableInterrupts(); Sound_Tone(4780); } else if (current_switch == 0x02){ EnableInterrupts(); Sound_Tone(4259); } else if (current_switch == 0x04){ EnableInterrupts(); Sound_Tone(3794); } else if (current_switch == 0x08){ EnableInterrupts(); Sound_Tone(3189); } // else if (current_switch == 0x00){ // Sound_Off(); // DisableInterrupts(); // } delay(10); } }
void SysTick_Handler(void){ GPIO_PORTF_DATA_R ^= 0x04; // Toggle Heartbeat uint32_t pianoInput = Piano_In(); if (pianoInput == 1){ Sound_Play(4778); // C } else if(pianoInput == 2){ Sound_Play(4257); // D } else if(pianoInput == 4){ Sound_Play(3792); // F } else if(pianoInput == 8){ Sound_Play(3189); // G } else if(pianoInput == 3){ Sound_Play(2841); // A } else if(pianoInput == 6){ Sound_Play(19111); // A } }}
int main(void) { unsigned long input= 0; PLL_Init(); Sound_Init(); // initialize SysTick timer and DAC Piano_Init(); EnableInterrupts(); // enable after all initialization are done while(1) { // input from keys to select tone input= Piano_In(); switch (input) { case 0x01: Sound_Tone(C); break; case 0x10: Sound_Tone(D); break; case 0x04: Sound_Tone(E); break; case 0x08: Sound_Tone(G); break; default: Sound_Off(); break; } } }
int main(void){ // Real Lab13 // for the real board grader to work // you must connect PD3 to your DAC output TExaS_Init(SW_PIN_PE3210, DAC_PIN_PB3210,ScopeOn); // activate grader and set system clock to 80 MHz // PortE used for piano keys, PortB used for DAC Sound_Init(); // initialize SysTick timer and DAC Piano_Init(); EnableInterrupts(); // enable after all initialization are done while(1){ /*DAC_Out(wave[n]); // your code to output to the DAC delay(1000); // wait 1s (later change this to 1ms) n = (n+1)&0x1F;*/ switch(Piano_In()) { case C: delay(delayValue); //EnableInterrupts(); //Sound_Tone(523.251); Sound_Tone(C0); break; case D: //EnableInterrupts(); delay(delayValue); Sound_Tone(D0); break; case E: //EnableInterrupts(); delay(delayValue); Sound_Tone(E0); break; case G: //EnableInterrupts(); delay(delayValue); Sound_Tone(G0); break; default: delay(delayValue); Sound_Off(); //DisableInterrupts(); break; } } }
void main(void) { PLL_Init(); // Engaging PLL allows use to run 9S12 at 24MHz even in RUN mode DAC_Init(); Piano_Init(); Sound_Init(); EnableInterrupts; Data = 0; for(ever) { Piano_In(); PTP ^= 0x80; // Heartbeat } /* for(;;) { DAC_Out(Data); Data = 0x0F&(Data+1); } */ }