#include #include #define ratio 50; //ratio is the voltage divider ratio. const unsigned int count = 40; //count is number of clock cycles/pwm period. const unsigned int K = 4096/2.5/ratio; //K is the "ticks"/volt conversion unsigned int x,y; unsigned char h = 0; void startxtal(); //void boost(unsigned int VoK,unsigned int _4count); void interferential2(unsigned int count, unsigned int K); void interferential4(unsigned int count, unsigned int K); void TENS(unsigned int count, unsigned int K); void Hivolt(unsigned int count, unsigned int K); void russian(unsigned int count, unsigned int K); void choose(); void LED(unsigned char h); void main(void) { WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer P6SEL |= 0x10; // Enable A/D channel A4 ADC12CTL0 = ADC12ON+SHT0_2+REFON+REF2_5V; // Turn on ADC12, set sampling time ADC12CTL1 = SHP; // Use sampling timer ADC12MCTL0 = SREF_1 + 4; // Vr+=Vref+ //ADC12MCTL0 = SREF_1 + 0x0A; // Vr+=Vref+ P5DIR = 0xff; P2DIR = 0x40; P2OUT = 0x00; P5OUT = 0x00; for ( x=0; x<0x3600; x++) // Delay for reference start-up { } P5OUT = 0x00; for(y = 0;y < 16; y++) { if (P5OUT == 7) P5OUT = 0 ; else P5OUT++; if (h == 8) h = 0; else LED(h++); for(x = 0;x < 5000; x++) _NOP(); } startxtal(); for(y = 0;y < 16; y++) { if (P5OUT == 7) P5OUT = 0 ; else P5OUT++; if (h == 8) h = 0; else LED(h++); for(x = 0;x < 50000; x++) _NOP(); LED(10); } P4DIR |= 0x7e; // P4.1 - P4.6 output P4SEL |= 0x7e; // P4.1 - P4.6 TBx options TBCCR0 = count; // PWM Period TBCCTL1 = OUTMOD_7; // CCR1 reset/set TBCCR1 = 0; // CCR1 PWM duty cycle TBCCTL2 = OUTMOD_7; TBCCR2 = 0; TBCCTL3 = OUTMOD_3; TBCCR3 = 0; TBCCTL4 = OUTMOD_3; TBCCR4 = 0; TBCCTL5 = OUTMOD_7; TBCCR5 = 0; TBCTL = TBSSEL_1 + MC_1; // SMCLK, up mode choose(); } ///////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// /////////////////////////////////////////////////////// void choose() { unsigned char j = 0,g = 0,x = 0; P5OUT = 0x00; P2OUT &= 0xBF; for (x = 0;x<100;x++) _NOP(); h = 1; while (1) { j = (P2IN & 0x3f); switch (h) { case 1: if (P2IN & 0x80) { P5OUT |=0x01; interferential2(count,K); }break; case 2: if (P2IN & 0x80) { P5OUT |=0x02; interferential4(count,K); }break; case 3: if (P2IN & 0x80) { P5OUT |=0x03; russian(count,K); }break; case 4: if (P2IN & 0x80) { P5OUT |= 0x04; TENS(count,K); }break; case 5: if (P2IN & 0x80) { P5OUT |= 0x05; Hivolt(count,K); }break; } if (j != (P2IN & 0x3f)) { if (++h >=6) h = 1; } LED(h); for (x = 0;x<10000;x++) _NOP(); } } ////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// void startxtal(void) { //************************************************* int i,j; // Select LFXT1 high-3 oscillator BCSCTL1 |= XTS; // Turn on LFXT1 oscillator _BIC_SR(OSCOFF); // Wait for xtal to stabilize (Only try 10 times) for(j=0; j < 10; j++) { // Clear oscfault flag IFG1 &= ~OFIFG; // Delay for(i=0;i<0xFFFF;i++); if(!(IFG1 & OFIFG)) break; // Break if we stabilized } // Switch to the xtal BCSCTL2 |= SELM0 | SELM1; //******************************************************* } void LED(unsigned char h) { //setting LEDs to binary readout unsigned char g; if (h > 7) h = 7; g = h; P5OUT &= 0xE7; P2OUT &= 0xBF; if (g >= 4) { g -= 4; P5OUT |= 0x08; } if (g >= 2) { g -= 2; P5OUT |= 0x10; } if (g) P2OUT |= 0x40; } /*void boost(unsigned int VoK,unsigned int _4count) { unsigned int x = 0; unsigned int g = 0; unsigned int m = 0; ADC12CTL0 |= ADC12SC; for (x = 0;x<20;x++) _NOP(); m = ADC12MEM0; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty }*/ /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void interferential2(unsigned int count,unsigned int K) { //------------------function start---------------------- unsigned int g = 0,m = 0,n = 0,r = 0,j = 0,b = 0,i = 0,o = 0, beatperiod = 51; unsigned int sine[50]; const unsigned int _4count = 0.4*count; unsigned int Vo = 50; // Vo is desired output voltage unsigned int VoK = Vo*K; unsigned int *pCurSine1 = sine,*pCurSine2 = sine; for (n = 0; n < 50; n++) //initializing sine[] sine[n] = (0.8*count/2)*sin(2*3.14159*n/50)+count/2; ADC12CTL0 |= ENC; // Enable conversions ADC12CTL0 |= ADC12SC; // Start conversion //------------------repeatinging loop1-------------------------------------- while (1) { g = ((VoK - m)>>4); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //------------------repeatinging loop2-------------------------------------- if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeatinging loop3------------------------------------------ if (!(P2IN & 0x80)) { TBCCR1 = 0; TBCCR2 = 0; TBCCR5 = 0; choose(); } if (j != (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeatinging loop4--------------------------------- if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (VoK >3232) VoK = 3232; if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //------------------repeatinging loop5-------------------------------------- m = ADC12MEM0; ADC12CTL0 |= ADC12SC; // Start conversion if (r++ >= beatperiod) //to bump channel1 ahead of ch2 { if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; r = 0; } if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeating loop6------------------- if (i != (P2IN & 0x04)) beatperiod +=10; i = (P2IN & 0x04); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeating loop7------------------- if (o != (P2IN & 0x08)) beatperiod -=10; o = (P2IN & 0x08); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; } } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void interferential4(unsigned int count,unsigned int K) { //------------------function start---------------------- unsigned int g = 0,m = 0,n = 0,r = 0,j = 0,b = 0,i = 0,o = 0, beatperiod = 51; unsigned int sine[50]; const unsigned int _4count = 0.4*count; unsigned int Vo = 50; // Vo is desired output voltage unsigned int VoK = Vo*K; unsigned int *pCurSine1 = sine,*pCurSine2 = sine; for (n = 0; n < 50; n++) //initializing sine[] sine[n] = (0.8*count/2)*sin(2*3.14159*n/50)+count/2; ADC12CTL0 |= ENC; // Enable conversions ADC12CTL0 |= ADC12SC; // Start conversion //------------------repeatinging loop1-------------------------------------- while (1) { g = ((VoK - m)>>4); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //------------------repeatinging loop2-------------------------------------- if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //----------------------repeatinging loop3------------------------------------------ if (!(P2IN & 0x80)) { TBCCR1 = 0; TBCCR2 = 0; TBCCR5 = 0; choose(); } if (j != (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //----------------------repeatinging loop4--------------------------------- if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (VoK >3232) VoK = 3232; if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //------------------repeatinging loop5-------------------------------------- m = ADC12MEM0; ADC12CTL0 |= ADC12SC; // Start conversion if (r++ >= beatperiod) //to bump channel1 ahead of ch2 { if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; r = 0; } if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //----------------------repeating loop6------------------- if (i != (P2IN & 0x04)) beatperiod +=10; i = (P2IN & 0x04); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //----------------------repeating loop7------------------- if (o != (P2IN & 0x08)) beatperiod -=10; o = (P2IN & 0x08); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; } } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void TENS(unsigned int count, unsigned int K) { unsigned int Vo = 40; //desired output voltage unsigned int VoK = Vo*K; const unsigned int K1 = 60000; // in units of seconds const unsigned int K2 = 1; //in units of 1/uS const unsigned int _4count = 0.4*count; unsigned int pulsewidth = 50; //self explanatory, moron unsigned int prf = 200; //pulse repitition frequency in Hz unsigned int r = 0; unsigned int x = 0; unsigned int g = 0; unsigned int m = 0; unsigned int j = 0, b = 0,q = 0,w = 0,p = 0,l = 0; //variables for buttons P5DIR = 0xff; //P5.0-P5.4 are LEDs, in order 34521x P5.5 and P5.6 signal TENS output ADC12CTL0 |= ADC12SC; for (x=0;x<1000;x++) _NOP(); while (1) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty if (j != (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (q != (P2IN & 0x04)) pulsewidth++; q = (P2IN & 0x04); if (w != (P2IN & 0x08)) pulsewidth--; w = (P2IN & 0x08); if (p != (P2IN & 0x10)) prf++; p = (P2IN & 0x10); if (l != (P2IN & 0x20)) prf--; l = (P2IN & 0x20); if (!(P2IN & 0x80)) { TBCCR5 = 0; choose(); } if (VoK <=320) VoK = 320; if (VoK >=3232) VoK = 3232; h = VoK/404; LED(h); if (prf < 5) prf = 5; if (prf > 400) prf = 400; if (pulsewidth < 5) pulsewidth = 5; if (pulsewidth > 100) pulsewidth = 100; if (r++ > K1/prf) { r = 0; P5OUT += 0x40; //P5.6 on for (x = 0; (x < K2*pulsewidth) ; x++) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty } P5OUT -= 0x20; // P5.6 off P5.5 on for (x = 0; (x < K2*pulsewidth); x++) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty } P5OUT -= 0x20; // P5.5 and P5.6 off } } } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void Hivolt(unsigned int count, unsigned int K) { unsigned int Vo = 40; //desired output voltage unsigned int VoK = Vo*K; const unsigned int K1 = 60000; // in units of seconds const unsigned int K2 = 1; //in units of 1/uS const unsigned int _4count = 0.4*count; unsigned int pulsewidth = 2; //self explanatory, moron unsigned int prf = 200; //pulse repitition frequency in Hz unsigned int r = 0; unsigned int x = 0; unsigned int g = 0; unsigned int m = 0; unsigned int j = 0, b = 0,q = 0,w = 0,p = 0,l = 0; //variables for buttons P5DIR = 0xff; //P5.0-P5.4 are LEDs, in order 34521x P5.5 and P5.6 signal TENS output ADC12CTL0 |= ADC12SC; for (x=0;x<1000;x++) _NOP(); while (1) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty if (j != (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (p != (P2IN & 0x10)) prf++; p = (P2IN & 0x10); if (l != (P2IN & 0x20)) prf--; l = (P2IN & 0x20); if (!(P2IN & 0x80)) { TBCCR5 = 0; choose(); } if (VoK <=320) VoK = 320; if (VoK >=3232) VoK = 3232; h = VoK/404; LED(h); if (prf < 5) prf = 5; if (prf > 400) prf = 400; if (r++ > K1/prf) { r = 0; P5OUT += 0x80; //P5.7 on for (x = 0; (x < K2*pulsewidth) ; x++) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty } P5OUT -=0x80; //P5.7 off for (x = 0; (x < 40) ; x++) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty } P5OUT += 0x80; //P5.7 on for (x = 0; (x < K2*pulsewidth) ; x++) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty } P5OUT -=0x80; //P5.7 off } } } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void russian(unsigned int count, unsigned int K) { //------------------function start---------------------- const unsigned int _4count = 0.4*count; unsigned int freq = 50, x = 0, dutycycle = 90, K2 = 60000, n = 0;//duty cycle isnt quite right "50" = 10% unsigned int K2freqDC = dutycycle*K2/freq, K2freq_DC = (100-dutycycle)*K2/freq; unsigned int j = 0, b = 0,q = 0,w = 0,p = 0,l = 0; //variables for buttons unsigned int Vo = 50; // Vo is desired output voltage unsigned int VoK = Vo*K; unsigned int sine[100]; unsigned int *pCurSine1 = sine,*pCurSine2 = sine + 50; unsigned int g = 0; unsigned int m = 0; for (n = 0; n < 100; n++) //initializing sine[] sine[n] = (0.8*count/2)*sin(2*3.14159*n/100)+count/2; ADC12CTL0 |= ENC; // Enable conversions /* TBCCTL1 = OUTMOD_7; // CCR1 reset/set TBCCR1 = 0; // CCR1 PWM duty cycle TBCCTL2 = OUTMOD_7; TBCCR2 = 0; TBCCTL3 = OUTMOD_7; TBCCR3 = 0; TBCCTL4 = OUTMOD_7; TBCCR4 = 0; TBCTL = TBSSEL_1 + MC_1; // SMCLK, up mode */ ADC12CTL0 |= ADC12SC; // Start conversion while (1) { for (x = 0; x < K2freqDC; x++) { g = ((VoK - m)>>4); if (pCurSine1 >= &sine[99]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[99]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //------------------repeatinging loop2-------------------------------------- if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty if (pCurSine1 >= &sine[99]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[99]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeatinging loop3------------------------------------------ if (!(P2IN & 0x80)) { TBCCR1 = 0; TBCCR2 = 0; TBCCR5 = 0; choose(); } if (j != (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (pCurSine1 >= &sine[99]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[99]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeatingingloop4--------------------------------- if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (VoK >3232) VoK = 3232; if (pCurSine1 >= &sine[99]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[99]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //------------------repeatinging loop5-------------------------------------- m = ADC12MEM0; ADC12CTL0 |= ADC12SC; // Start conversion } /* { ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty m = ADC12MEM0; if (pCurSine1 == &sine[35]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 == &sine[35]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; } */ for (x = 0; x < K2freq_DC; x++) { ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty m = ADC12MEM0; /* if (pCurSine1 == &sine[99]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 == &sine[99]) pCurSine2 = sine; else pCurSine2++; */ TBCCR1 = 0; TBCCR2 = 0; if (j < (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (q != (P2IN & 0x04)) dutycycle++; q = (P2IN & 0x04); if (w != (P2IN & 0x08)) dutycycle--; w = (P2IN & 0x08); if (p != (P2IN & 0x10)) freq++; p = (P2IN & 0x10); if (l != (P2IN & 0x20)) freq--; l = (P2IN & 0x20); if (!(P2IN & 0x80)) { TBCCR5 = 0; TBCCR1 = 0; TBCCR2 = 0; choose(); } if (dutycycle <= 0) dutycycle = 0; if (dutycycle >= 100) dutycycle = 100; if (freq <=25) freq = 25; if (freq >=250) freq = 250; if (VoK <=320) VoK = 320; if (VoK >=3232) VoK = 3232; h = VoK/404; LED(h); K2freqDC = dutycycle*K2/freq; K2freq_DC = (100-dutycycle)*K2/freq; } } } #include #include #define ratio 50; //ratio is the voltage divider ratio. const unsigned int count = 40; //count is number of clock cycles/pwm period. const unsigned int K = 4096/2.5/ratio; //K is the "ticks"/volt conversion unsigned int x,y; unsigned char h; void startxtal(); //void boost(unsigned int VoK,unsigned int _4count); void interferential2(unsigned int count, unsigned int K); void interferential4(unsigned int count, unsigned int K); void TENS(unsigned int count, unsigned int K); void Hivolt(unsigned int count, unsigned int K); void russian(unsigned int count, unsigned int K); void choose(); void LED(unsigned char h); void main(void) { WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer P6SEL |= 0x10; // Enable A/D channel A4 ADC12CTL0 = ADC12ON+SHT0_2+REFON+REF2_5V; // Turn on ADC12, set sampling time ADC12CTL1 = SHP; // Use sampling timer ADC12MCTL0 = SREF_1 + 4; // Vr+=Vref+ //ADC12MCTL0 = SREF_1 + 0x0A; // Vr+=Vref+ P5DIR = 0xff; P2DIR = 0x40; P5OUT = 0x02; for ( x=0; x<0x3600; x++) // Delay for reference start-up { } P5OUT = 0x00; for(y = 0;y < 50; y++) { P5OUT =0x02; for(x = 0;x < 100; x++); P5OUT =0x00; for(x = 0;x < 100; x++); } startxtal(); for(y = 0;y < 50; y++) { P5OUT =0x02; for(x = 0;x < 10; x++); P5OUT =0x00; for(x = 0;x < 10; x++); } P4DIR |= 0x7e; // P4.1 - P4.6 output P4SEL |= 0x7e; // P4.1 - P4.6 TBx options TBCCR0 = count; // PWM Period TBCCTL1 = OUTMOD_7; // CCR1 reset/set TBCCR1 = 0; // CCR1 PWM duty cycle TBCCTL2 = OUTMOD_7; TBCCR2 = 0; TBCCTL3 = OUTMOD_3; TBCCR3 = 0; TBCCTL4 = OUTMOD_3; TBCCR4 = 0; TBCCTL5 = OUTMOD_7; TBCCR5 = 0; TBCTL = TBSSEL_1 + MC_1; // SMCLK, up mode choose(); } ///////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// /////////////////////////////////////////////////////// void choose() { unsigned char j = 0,g = 0,x = 0; P5OUT = 0x10; for (x = 0;x<100;x++) _NOP(); h = 0; while (1) { j = (P2IN & 0x3f); if ((h == 1) && (P2IN & 0x80)) { P5OUT |=0x01; interferential2(count,K); }; if ((h == 2) && (P2IN & 0x80)) { P5OUT |=0x02; interferential4(count,K); }; if ((h == 3) && (P2IN & 0x80)) { P5OUT |=0x03; russian(count,K); }; if ((h == 4) && (P2IN & 0x80)) { P5OUT |= 0x04; TENS(count,K); }; if ((h == 5) && (P2IN & 0x80)) { P5OUT |= 0x05; Hivolt(count,K); }; if (j != (P2IN & 0x3f)) { if (++h >=6) h = 1; }; /* j = (P2IN & 0x80); if ((h == 1) && (P2IN & 0x3f)) { P5OUT |=0x01; interferential(count,K); }; if ((h == 2) && (P2IN & 0x3f)) { P5OUT |=0x02; russian(count,K); }; if ((h == 3) && (P2IN & 0x3f)) { P5OUT |= 0x03; TENS(count,K); }; if (j < (P2IN & 0x80)) { if (++h >=4) h = 1; */ LED(h); /* //setting LEDs to binary readout g = h; P5OUT &= 0xE3; if (g >= 4) { g -= 4; P5OUT |= 0x04; }; if (g >= 2) { g -= 2; P5OUT |= 0x08; }; if (g) P5OUT |= 0x10; }; */ //if (h >=4) h = 1; shouldnt need this line? for (x = 0;x<100;x++) _NOP(); } } ////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// void startxtal(void) { //************************************************* int i,j; // Select LFXT1 high-3 oscillator BCSCTL1 |= XTS; // Turn on LFXT1 oscillator _BIC_SR(OSCOFF); // Wait for xtal to stabilize (Only try 10 times) for(j=0; j < 10; j++) { // Clear oscfault flag IFG1 &= ~OFIFG; // Delay for(i=0;i<0xFFFF;i++); if(!(IFG1 & OFIFG)) break; // Break if we stabilized } // Switch to the xtal BCSCTL2 |= SELM0 | SELM1; //******************************************************* } void LED(unsigned char h) { //setting LEDs to binary readout unsigned char g; if (h > 7) h = 7; g = h; P5OUT &= 0xE3; if (g >= 4) { g -= 4; P5OUT |= 0x04; }; if (g >= 2) { g -= 2; P5OUT |= 0x08; }; if (g) P5OUT |= 0x10; } /*void boost(unsigned int VoK,unsigned int _4count) { unsigned int x = 0; unsigned int g = 0; unsigned int m = 0; ADC12CTL0 |= ADC12SC; for (x = 0;x<20;x++) _NOP(); m = ADC12MEM0; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty }*/ /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void interferential2(unsigned int count,unsigned int K) { //------------------function start---------------------- unsigned int g = 0,m = 0,n = 0,r = 0,j = 0,b = 0,i = 0,o = 0, beatperiod = 51; unsigned int sine[50]; const unsigned int _4count = 0.4*count; unsigned int Vo = 50; // Vo is desired output voltage unsigned int VoK = Vo*K; unsigned int *pCurSine1 = sine,*pCurSine2 = sine; for (n = 0; n < 50; n++) //initializing sine[] sine[n] = (0.8*count/2)*sin(2*3.14159*n/50)+count/2; ADC12CTL0 |= ENC; // Enable conversions ADC12CTL0 |= ADC12SC; // Start conversion //------------------repeatinging loop1-------------------------------------- while (1) { g = ((VoK - m)>>4); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //------------------repeatinging loop2-------------------------------------- if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeatinging loop3------------------------------------------ if (!(P2IN & 0x80)) { TBCCR1 = 0; TBCCR2 = 0; TBCCR5 = 0; choose(); }; if (j != (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeatinging loop4--------------------------------- if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (VoK >3232) VoK = 3232; if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //------------------repeatinging loop5-------------------------------------- m = ADC12MEM0; ADC12CTL0 |= ADC12SC; // Start conversion if (r++ >= beatperiod) //to bump channel1 ahead of ch2 { if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; r = 0; } if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeating loop6------------------- if (i != (P2IN & 0x04)) beatperiod +=10; i = (P2IN & 0x04); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeating loop7------------------- if (o != (P2IN & 0x08)) beatperiod -=10; o = (P2IN & 0x08); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; } } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void interferential4(unsigned int count,unsigned int K) { //------------------function start---------------------- unsigned int g = 0,m = 0,n = 0,r = 0,j = 0,b = 0,i = 0,o = 0, beatperiod = 51; unsigned int sine[50]; const unsigned int _4count = 0.4*count; unsigned int Vo = 50; // Vo is desired output voltage unsigned int VoK = Vo*K; unsigned int *pCurSine1 = sine,*pCurSine2 = sine; for (n = 0; n < 50; n++) //initializing sine[] sine[n] = (0.8*count/2)*sin(2*3.14159*n/50)+count/2; ADC12CTL0 |= ENC; // Enable conversions ADC12CTL0 |= ADC12SC; // Start conversion //------------------repeatinging loop1-------------------------------------- while (1) { g = ((VoK - m)>>4); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //------------------repeatinging loop2-------------------------------------- if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //----------------------repeatinging loop3------------------------------------------ if (!(P2IN & 0x80)) { TBCCR1 = 0; TBCCR2 = 0; TBCCR5 = 0; choose(); }; if (j != (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //----------------------repeatinging loop4--------------------------------- if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (VoK >3232) VoK = 3232; if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //------------------repeatinging loop5-------------------------------------- m = ADC12MEM0; ADC12CTL0 |= ADC12SC; // Start conversion if (r++ >= beatperiod) //to bump channel1 ahead of ch2 { if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; r = 0; } if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //----------------------repeating loop6------------------- if (i != (P2IN & 0x04)) beatperiod +=10; i = (P2IN & 0x04); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; //----------------------repeating loop7------------------- if (o != (P2IN & 0x08)) beatperiod -=10; o = (P2IN & 0x08); if (pCurSine1 >= &sine[49]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[49]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = TBCCR3 = *pCurSine1; TBCCR2 = TBCCR4 = *pCurSine2; } } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void TENS(unsigned int count, unsigned int K) { unsigned int Vo = 40; //desired output voltage unsigned int VoK = Vo*K; const unsigned int K1 = 60000; // in units of seconds const unsigned int K2 = 1; //in units of 1/uS const unsigned int _4count = 0.4*count; unsigned int pulsewidth = 50; //self explanatory, moron unsigned int prf = 200; //pulse repitition frequency in Hz unsigned int r = 0; unsigned int x = 0; unsigned int g = 0; unsigned int m = 0; unsigned int j = 0, b = 0,q = 0,w = 0,p = 0,l = 0; //variables for buttons P5DIR = 0xff; //P5.0-P5.4 are LEDs, in order 34521x P5.5 and P5.6 signal TENS output ADC12CTL0 |= ADC12SC; for (x=0;x<1000;x++) _NOP(); while (1) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty if (j != (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (q != (P2IN & 0x04)) pulsewidth++; q = (P2IN & 0x04); if (w != (P2IN & 0x08)) pulsewidth--; w = (P2IN & 0x08); if (p != (P2IN & 0x10)) prf++; p = (P2IN & 0x10); if (l != (P2IN & 0x20)) prf--; l = (P2IN & 0x20); if (!(P2IN & 0x80)) { TBCCR5 = 0; choose(); }; if (VoK <=320) VoK = 320; if (VoK >=3232) VoK = 3232; h = VoK/404; LED(h); if (prf < 5) prf = 5; if (prf > 400) prf = 400; if (pulsewidth < 5) pulsewidth = 5; if (pulsewidth > 100) pulsewidth = 100; if (r++ > K1/prf) { r = 0; P5OUT += 0x40; //P5.6 on for (x = 0; (x < K2*pulsewidth) ; x++) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty }; P5OUT -= 0x20; // P5.6 off P5.5 on for (x = 0; (x < K2*pulsewidth); x++) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty }; P5OUT -= 0x20; // P5.5 and P5.6 off }; } } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void Hivolt(unsigned int count, unsigned int K) { unsigned int Vo = 40; //desired output voltage unsigned int VoK = Vo*K; const unsigned int K1 = 60000; // in units of seconds const unsigned int K2 = 1; //in units of 1/uS const unsigned int _4count = 0.4*count; unsigned int pulsewidth = 2; //self explanatory, moron unsigned int prf = 200; //pulse repitition frequency in Hz unsigned int r = 0; unsigned int x = 0; unsigned int g = 0; unsigned int m = 0; unsigned int j = 0, b = 0,q = 0,w = 0,p = 0,l = 0; //variables for buttons P5DIR = 0xff; //P5.0-P5.4 are LEDs, in order 34521x P5.5 and P5.6 signal TENS output ADC12CTL0 |= ADC12SC; for (x=0;x<1000;x++) _NOP(); while (1) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty if (j != (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (p != (P2IN & 0x10)) prf++; p = (P2IN & 0x10); if (l != (P2IN & 0x20)) prf--; l = (P2IN & 0x20); if (!(P2IN & 0x80)) { TBCCR5 = 0; choose(); }; if (VoK <=320) VoK = 320; if (VoK >=3232) VoK = 3232; h = VoK/404; LED(h); if (prf < 5) prf = 5; if (prf > 400) prf = 400; if (r++ > K1/prf) { r = 0; P5OUT += 0x80; //P5.7 on for (x = 0; (x < K2*pulsewidth) ; x++) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty }; P5OUT -=0x80; //P5.7 off for (x = 0; (x < 40) ; x++) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty }; P5OUT += 0x80; //P5.7 on for (x = 0; (x < K2*pulsewidth) ; x++) { m = ADC12MEM0; ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty }; P5OUT -=0x80; //P5.7 off }; } } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void russian(unsigned int count, unsigned int K) { //------------------function start---------------------- const unsigned int _4count = 0.4*count; unsigned int freq = 50, x = 0, dutycycle = 90, K2 = 60000, n = 0;//duty cycle isnt quite right "50" = 10% unsigned int K2freqDC = dutycycle*K2/freq, K2freq_DC = (100-dutycycle)*K2/freq; unsigned int j = 0, b = 0,q = 0,w = 0,p = 0,l = 0; //variables for buttons unsigned int Vo = 50; // Vo is desired output voltage unsigned int VoK = Vo*K; unsigned int sine[100]; unsigned int *pCurSine1 = sine,*pCurSine2 = sine + 50; unsigned int g = 0; unsigned int m = 0; for (n = 0; n < 100; n++) //initializing sine[] sine[n] = (0.8*count/2)*sin(2*3.14159*n/100)+count/2; ADC12CTL0 |= ENC; // Enable conversions /* TBCCTL1 = OUTMOD_7; // CCR1 reset/set TBCCR1 = 0; // CCR1 PWM duty cycle TBCCTL2 = OUTMOD_7; TBCCR2 = 0; TBCCTL3 = OUTMOD_7; TBCCR3 = 0; TBCCTL4 = OUTMOD_7; TBCCR4 = 0; TBCTL = TBSSEL_1 + MC_1; // SMCLK, up mode */ ADC12CTL0 |= ADC12SC; // Start conversion while (1) { for (x = 0; x < K2freqDC; x++) { g = ((VoK - m)>>4); if (pCurSine1 >= &sine[99]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[99]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //------------------repeatinging loop2-------------------------------------- if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty if (pCurSine1 >= &sine[99]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[99]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeatinging loop3------------------------------------------ if (!(P2IN & 0x80)) { TBCCR1 = 0; TBCCR2 = 0; TBCCR5 = 0; choose(); }; if (j != (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (pCurSine1 >= &sine[99]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[99]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //----------------------repeatinging loop4--------------------------------- if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (VoK >3232) VoK = 3232; if (pCurSine1 >= &sine[99]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 >= &sine[99]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; //------------------repeatinging loop5-------------------------------------- m = ADC12MEM0; ADC12CTL0 |= ADC12SC; // Start conversion }; /* { ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty m = ADC12MEM0; if (pCurSine1 == &sine[35]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 == &sine[35]) pCurSine2 = sine; else pCurSine2++; TBCCR1 = *pCurSine1; TBCCR2 = *pCurSine2; }; */ for (x = 0; x < K2freq_DC; x++) { ADC12CTL0 |= ADC12SC; g = ((VoK - m)>>4); if (m > VoK) g = 0; if (g > (_4count)) g = (_4count); TBCCR5 = g; // CCR1 PWM duty m = ADC12MEM0; /* if (pCurSine1 == &sine[99]) pCurSine1 = sine; else pCurSine1++; if (pCurSine2 == &sine[99]) pCurSine2 = sine; else pCurSine2++; */ TBCCR1 = 0; TBCCR2 = 0; if (j < (P2IN & 0x01)) VoK += K; j = (P2IN & 0x01); if (b != (P2IN & 0x02)) VoK -= K; b = (P2IN & 0x02); if (q != (P2IN & 0x04)) dutycycle++; q = (P2IN & 0x04); if (w != (P2IN & 0x08)) dutycycle--; w = (P2IN & 0x08); if (p != (P2IN & 0x10)) freq++; p = (P2IN & 0x10); if (l != (P2IN & 0x20)) freq--; l = (P2IN & 0x20); if (!(P2IN & 0x80)) { TBCCR5 = 0; TBCCR1 = 0; TBCCR2 = 0; choose(); }; if (dutycycle <= 0) dutycycle = 0; if (dutycycle >= 100) dutycycle = 100; if (freq <=25) freq = 25; if (freq >=250) freq = 250; if (VoK <=320) VoK = 320; if (VoK >=3232) VoK = 3232; h = VoK/404; LED(h); K2freqDC = dutycycle*K2/freq; K2freq_DC = (100-dutycycle)*K2/freq; }; }; }