The cases must be constants, they may not be variables. May I suggest that you buy a book on C or "A Book on C?" Doug Hewett, CSDP -----Original Message----- From: Rodrigo Real [mailto:rodrigo@FREEDOM.IND.BR] Sent: Friday, September 26, 2003 8:27 AM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [EE:] need help on c code andre abelian writes: > 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 > It is strange the error you are having. Did you tried to do (x+28) instead of (28+x)? Or even, before the switch execute x=x+28; ? Rodrigo > > 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. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.