In C, the switch{} case values must be constant expressions. They are evaluated at comile time. You cannot have an X in a case. You'll have to implement your condition another way. Jon > -----Original Message----- > From: andre abelian [mailto:engelec@EARTHLINK.NET] > Sent: 25 September 2003 23:22 > To: PICLIST@MITVMA.MIT.EDU > Subject: [EE:] need help on c code > > > Hi to all engineers, > > Some thing I can't figure out any help will appreciate. > I have timer0 on high priority ISR and adc on low priority. I > need to add adc result in timer0 ISR example. in timer0 I > have case(28+0) I needed to be case(28+x) any time I change 0 > to x I get error massage > > Error[000] power_inveter.c 104 : constant expression required > > x is adc result register I need to either add or subtract > when I do this #define unsigned int x=5; it works but it is > constant number is not going to work for me I need that > number to come from ADC. My adc works when I check x register > I see numbers are chenging > > Andre > > Here is the code > > void interrupt HI_ISR(void) > { > if((TMR0IF)&&(TMR0IE)) > { > CLRWDT(); // clear WDT > TMR0IF=0; // clear interrupt flag > TMR0L=119; // timer0 > should get 46,25 > us > switch (count) // check count register > 0-360 > { > case (0): topgd=0; // 0 degree > bottomgd=1; // > topga=0; // > bottomga=1; // > count++; break; // > case (28+x): bottomga=0; count++; break; // > case (30+0): topgd=0; // > bottomgd=1; // > topga=1; // > count++; break; // > case (152-0): bottomgd=0; count++; break; // > case (154-0): topgd=1; // > topga=1; // > bottomga=0; // > count++; break; // > case (206+0): topga=0; count++; break; // > case (208+0): topgd=1; // > bottomgd=0; // > bottomga=1; // > count++; break; // > case (330-0): topgd=0; count++; break; // > case (332-0): bottomgd=1; // > bottomga=1; // > topga=0; // > count++; break; // > case (360): topgd=0; // > bottomgd=1; // > topga=0; // > bottomga=1; // > count=0; // > default : count++; break; // > } > } > } > > void interrupt low_priority LOW_ISR(void) > //static void interrupt isr(void) > { > // unsigned int x; > if((ADIF)&&(ADIE)) > { > while(GODONE)continue; > ADIF=0; // clear A/D flag > x=(ADRESH*50/255); > // PORTB=ADRESH; > GODONE=1; // start new conversion > DelayUs(10); > adtest^=0x01; // togle led on/off > } > > > -- > http://www.piclist.com hint: The list server can filter out > subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.