Thanks for the help, Imre. You were right, I left NewMode as a local variable. void CheckDIPs(int &NewMode) fixes the problem. I should have know better... Tim -----Original Message----- From: Dr. Imre Bartfai [mailto:root@prof.pmmf.hu] Sent: Monday, May 01, 2000 11:16 PM To: Tim Crist Cc: PICLIST@MITVMA.MIT.EDU Subject: Re: CCS switch usage Hi, I think you did another mistake. NewMode is a local variable as I see. Thus, it won't return the value you assign to it. CCS recommends a trick here: write in the declaration void CheckDIPs(int & NewMode) { I hope this helps. Regards, Imre On Mon, 1 May 2000, Tim Crist wrote: > I'm having trouble recognizing a two pin dip switch on PortB. My code looks > like this: > > void CheckDIPs(NewMode) { //Check Dip Switches for Change of state > byte DIPs; > const int DIPMask = 0b00001100; > DIPs= PORTB & DIPMask; > DIPs= DIPs>>2; // I can see it working to here... > switch(DIPs) { > case 0 : NewMode = Mode1; > break; > case 1 : NewMode = Mode2; > break; > case 2 : NewMode = Mode3; > break; > case 3 : NewMode = Mode4; > break; > default : NewMode = Bonk; > break; > } > } > > Regardless of the state of PortB, this routine always defaults. I'm not > sure if it's this routine or the PortB setup. > Most likely this could be refined to one cryptic line of C code. Any > suggestions? My PortB setup looks like this in the corresponding *.h file > (as provided by CCS new project routine): > > #define PIN_B0 48 > #define PIN_B1 49 > #define PIN_B2 50 > #define PIN_B3 51 > #define PIN_B4 52 > #define PIN_B5 53 > #define PIN_B6 54 > #define PIN_B7 55 > #use fixed_io(B_OUTPUTS=PIN_B0,PIN_B1) > #byte port_B=6 > > > Thanks, > > Tim Crist > >