Hi. Note that it is not *only* the lines I showed that has to be changed. There are a few other things. It *should* work in absolute mode also, of course. I just didn't analyzed that. Absolute mode as such was not the cause of your problems. Now, relocatable mode has a number of benefits, besides of beeing a "modern" way of writing code and building apps, so I personaly think that you are doing right in trying it. Jan-Erik. Francois Robbertze wrote 2012-03-05 16:55: > Thanks Jan-Erik, I will try the relocatable mode. Have not done this > before... > > > ----- Original Message ----- > From: "Jan-Erik Soderholm" > To: "Microcontroller discussion list - Public." > Sent: Saturday, March 03, 2012 7:47 PM > Subject: Re: [PIC] Test and Set/Clear bit in Bank 1 > > >> Francois Robbertze wrote 2012-03-03 17:51: >>> I want to test and set a Flag in Bank 1 >>> >>> I am unable to set/test the 'FanOnFlag'. (I use a Macro to switch banks >>> eg. >>> #bank_1 and #bank_0) >>> >>> I have the following: >>> >>> LIST P =3D 16F873A >>> ; >>> ; >>> ; >>> #Define FanOnFlag BitFlag7,0 >>> ; >>> ; >>> ; >>> ;bank 1 >>> huns equ 0xA0 >>> tens equ 0xA1 >>> ones equ 0xA2 >>> BIN equ 0xA3 >>> Count equ 0xA4 >>> UpperT equ 0xA5 >>> LowerT equ 0xA6 >>> BitFlag7 equ 0xA7 >>> WorkTemp equ 0xA8 >>> ; >>> ; >>> ; >>> #bank_1 >>> bcf FanOnFlag >>> #bank_0 >>> ; >>> ; >>> ; >>> Main >>> call ReadTemp ;Read the Appliance Temperature >>> btfsc DallasErrorFlag ;Test for failure in dallas18B20 >>> goto DallasError ;Handle an Temperature sensor Error >>> >>> movf Temperature, W ;Temperature return in Var Temperature >>> #bank_1 >>> movwf WorkTemp >>> >>> movlw 0x40 ;Set Upper Temp =3D 32degC - 64 =3D 0x40 >>> movwf UpperT >>> >>> movlw 0x38 ;Set Lower Temp =3D 28degC - 56 =3D 0x38 >>> movwf LowerT >>> >>> call Thermostat ;check temperature of unit >>> #bank_0 >>> ; >>> ; >>> ; >>> Thermostat >>> btfss FanOnFlag ;test if fan is on >>> goto Fan_is_off ;NO - goto Fan_is_off >>> >>> movf WorkTemp, W ;test if temp is lower than Lower Limit >>> subwf LowerT, W >>> btfss STATUS, C ;skip if temp is lower than limit >>> return >>> >>> FanOff >>> bcf Fan >>> bcf FanOnFlag ;remember state >>> #bank_0 >>> return >>> >>> Fan_is_off >>> movf WorkTemp, W ;test if temperature is higher than Upper Limit >>> subwf UpperT, W >>> btfsc STATUS, C >>> return >>> >>> FanOn >>> bsf Fan >>> bsf FanOnFlag >>> return >>> >>> DallasError >>> bcf Fan >>> return >>> >>> ;**************************End of Thermostat >>> Routine************************ >>> ; >>> ; >>> >> >> Switch to relocatable mode. >> Then do something like : >> >> Myvars UDATA >> FanOnFlag RES 1 >> ... >> ... >> BANKSEL FanOnFlag >> bcf FanOnFlag >> >> For faster access to "flags" I'd use (no need for BANKSEL) : >> >> Myvars UDATA_SHR >> FanOnFlag RES 1 >> ... >> ... >> bcf FanOnFlag >> >> >> >> -- >> http://www.piclist.com PIC/SX FAQ& list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .