Presentation is loading. Please wait.

Presentation is loading. Please wait.

Home Audio System Stephen Whitaker March 2, 2009 Microcomputer Systems I Dr. Kepuska.

Similar presentations


Presentation on theme: "Home Audio System Stephen Whitaker March 2, 2009 Microcomputer Systems I Dr. Kepuska."— Presentation transcript:

1 Home Audio System Stephen Whitaker March 2, 2009 Microcomputer Systems I Dr. Kepuska

2 Home Audio System  Purpose  Code  ISR  Process Data  Demo

3 Home Audio System EX_INTERRUPT_HANDLER(Sport0_RX_ISR) {... switch (vol){ case 0x00://no LEDs Process_Datadown4();//volume muted break; case 0x01://1 LED Process_Datadown3();//volume level -4 break; case 0x03://2 LEDs Process_Datadown2();//volume level -3 break; case 0x07://3 LEDs Process_Datadown1();//volume level -2 break; case 0x0f://4 LEDs Process_Datadown();//volume level -1 break; case 0x1f://5 LEDs Process_Data();//volume base level break; case 0x3f://6 LEDs Process_Dataup();//volume level +1 break; default: Process_Data();//base volume level in case something goes wrong … } Home Audio SystemISR.c

4 Home Audio System EX_INTERRUPT_HANDLER(Timer0_ISR) {... if(vol==0x00) { if((ucActive_LED = ucActive_LED >> 1) == 0x00) ucActive_LED = 0x20;//LEDs blink "backwards" } if(vol==0x01) { if((ucActive_LED = ucActive_LED << 1) == 0x02) ucActive_LED = 0x01;//first LED blinks fowards } if(vol==0x03) { if((ucActive_LED = ucActive_LED << 1) == 0x04) ucActive_LED = 0x01;//first 2 LEDs blinks fowards } if(vol==0x07) { if((ucActive_LED = ucActive_LED << 1) == 0x08) ucActive_LED = 0x01;//first 3 LEDs blinks fowards } if(vol==0x0f) { if((ucActive_LED = ucActive_LED << 1) == 0x10) ucActive_LED = 0x01;//first 4 LEDs blinks fowards } if(vol==0x1f) { if((ucActive_LED = ucActive_LED << 1) == 0x20) ucActive_LED = 0x01;//first 5 LEDs blinks fowards } if(vol==0x3f) { if((ucActive_LED = ucActive_LED << 1) == 0x40) ucActive_LED = 0x01;//all 6 LEDs blinks fowards } //creation of safty bit so that there is always a blinking of LEDs if(ucActive_LED== 0) { ucActive_LED = 1; } … } Home Audio SystemISR.c cont.

5 Home Audio System EX_INTERRUPT_HANDLER(FlagA_ISR) {… //button pf8 decreases volume {if(vol==0x3f) vol=0x1f; else if(vol==0x1f) vol=0x0f; else if(vol==0x0f) vol=0x07; else if(vol==0x07) vol=0x03; else if(vol==0x03) vol=0x01; else if(vol==0x01) vol=0x00; } //button pf9 increases volume {if(vol==0x00) vol=0x01; else if(vol==0x01) vol=0x03; else if(vol==0x03) vol=0x07; else if(vol==0x07) vol=0x0f; else if(vol==0x0f) vol=0x1f; else if(vol==0x1f) vol=0x3f;} Home Audio SystemISR.c cont. //button pf10 changes low/high pass filters {if (state <2) ++state; else state=0; } //button pf11 turns off and on { FIO_ANOM_0311_FLAG_W(0x0800,pFIO_FLA G_C); if (dep <1) ++dep; else dep=0; }

6 Home Audio System Proccess_data.c void Process_Data(void)//base volume {iChannel0LeftOut = iChannel0LeftIn; iChannel0RightOut = iChannel0RightIn; } void Process_Dataup(void)//volume level +1 {iChannel0LeftOut = iChannel0LeftIn*2; iChannel0RightOut = iChannel0RightIn*2; } void Process_Datadown(void)//volume level -1 {const int BL = 8; const static float B[8] = {.9}; float yL_low=0; float yR_low=0; int counter_low; int i_low; static float xL_low[8]={0}; static float xR_low[8]={0}; for(i_low=BL-1;i_low>=0;i_low--) { xL_low[i_low+1]=xL_low[i_low]; xR_low[i_low+1]=xR_low[i_low]; } xL_low[0]=(float)(iChannel0LeftIn<<8); xR_low[0]=(float)(iChannel0RightIn<<8); for(counter_low=0;counter_low<BL;counter_low++) { yL_low+=B[counter_low]*xL_low[counter_low]; yR_low+=B[counter_low]*xR_low[counter_low]; } iChannel0LeftOut=(int)yL_low>>8; iChannel0RightOut=(int)yR_low>>8;} void Process_Datadown1(void) //volume level -2 {const int BL = 8; const static float B[8] = {.7}; float yL_low=0; float yR_low=0; int counter_low; int i_low; static float xL_low[8]={0}; static float xR_low[8]={0}; for(i_low=BL- 1;i_low>=0;i_low--) {xL_low[i_low+1]=xL_low[i_low]; xR_low[i_low+1]=xR_low[i_low] ; } xL_low[0]=(float)(iChannel0LeftIn<<8); xR_low[0]=(float)(iChannel0RightIn<<8); for(counter_low=0;counter_low<BL;count er_low++) { yL_low+=B[counter_low]*xL_low[counter _low]; yR_low+=B[counter_low]*xR_low[counte r_low]; } iChannel0LeftOut=(int)yL_low>>8; iChannel0RightOut=(int)yR_low>>8; }

7 Home Audio System Proccess_data.c cont. void Process_Datadown2(void)//volume level -3 { const int BL = 8; const static float B[8] = {.5}; float yL_low=0; float yR_low=0; int counter_low; int i_low; static float xL_low[8]={0}; static float xR_low[8]={0}; for(i_low=BL-1;i_low>=0;i_low--) { xL_low[i_low+1]=xL_low[i_low]; xR_low[i_low+1]=xR_low[i_low]; } xL_low[0]=(float)(iChannel0LeftIn<<8); xR_low[0]=(float)(iChannel0RightIn<<8); for(counter_low=0;counter_low<BL;count er_low++) { yL_low+=B[counter_low]*xL_low[counter_ low]; yR_low+=B[counter_low]*xR_low[counter _low]; } iChannel0LeftOut=(int)yL_low>>8; iChannel0RightOut=(int)yR_low>>8; } void Process_Datadown3(void)//volume level - 4 { const int BL = 8; const static float B[8] = {.3}; float yL_low=0; float yR_low=0; int counter_low; int i_low; static float xL_low[8]={0}; static float xR_low[8]={0}; for(i_low=BL-1;i_low>=0;i_low--) { xL_low[i_low+1]=xL_low[i_low]; xR_low[i_low+1]=xR_low[i_low]; } xL_low[0]=(float)(iChannel0LeftIn<<8); xR_low[0]=(float)(iChannel0RightIn<<8); for(counter_low=0;counter_low<BL;counter _low++) { yL_low+=B[counter_low]*xL_low[counter_low]; yR_low+=B[counter_low]*xR_low[counter_low]; } iChannel0LeftOut=(int)yL_low>>8; iChannel0RightOut=(int)yR_low>>8; } void Process_Datadown4(void)//volume level - 5 {iChannel0LeftOut = iChannel0LeftIn- iChannel0LeftIn; iChannel0RightOut = iChannel0RightIn- iChannel0RightIn;}

8 Home Audio System Proccess_data.c cont. void low(void)//lowpass { const int BL = 101; const static float B[101] = {...}; float yL_low=0; float yR_low=0; int counter_low; int i_low; static float xL_low[101]={0}; static float xR_low[101]={0}; for(i_low=BL-1;i_low>=0;i_low--) { xL_low[i_low+1]=xL_low[i_low]; xR_low[i_low+1]=xR_low[i_low]; } xL_low[0]=(float)(iChannel0LeftIn<<8); xR_low[0]=(float)(iChannel0RightIn<<8); for(counter_low=0;counter_low<BL;counter _low++) { yL_low+=B[counter_low]*xL_low[counter_lo w]; yR_low+=B[counter_low]*xR_low[counter_l ow]; } iChannel1LeftOut=(int)yL_low>>8; iChannel1RightOut=(int)yR_low>>8; }; void high(void)//highpass { const int BL = 101; const float A[101] = {...}; float yL_low=0; float yR_low=0; int counter_low; int i_low; static float xL_low[101]={0}; static float xR_low[101]={0}; for(i_low=BL-1;i_low>=0;i_low--) { xL_low[i_low+1]=xL_low[i_low]; xR_low[i_low+1]=xR_low[i_low]; } xL_low[0]=(float)(iChannel0LeftIn<<8); xR_low[0]=(float)(iChannel0RightIn<<8); for(counter_low=0;counter_low<BL;counter _low++) { yL_low+=A[counter_low]*xL_low[counter_lo w]; yR_low+=A[counter_low]*xR_low[counter_l ow]; } iChannel1LeftOut=(int)yL_low>>8; iChannel1RightOut=(int)yR_low>>8; };

9 Home Audio System Demo


Download ppt "Home Audio System Stephen Whitaker March 2, 2009 Microcomputer Systems I Dr. Kepuska."

Similar presentations


Ads by Google