Searching \ for '[PIC] Test and Set/Clear bit in Bank 1' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/memory.htm?key=bank
Search entire site for: 'Test and Set/Clear bit in Bank 1'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Test and Set/Clear bit in Bank 1'
2012\03\03@115148 by Francois Robbertze

flavicon
face
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 = 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 = 32degC - 64 = 0x40
movwf UpperT

movlw 0x38    ;Set Lower Temp = 28degC - 56 = 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************************
;
;

2012\03\03@124724 by Jan-Erik Soderholm

face picon face
Francois Robbertze wrote 2012-03-03 17:51:
{Quote hidden}

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

2012\03\05@105535 by Francois Robbertze

flavicon
face
Thanks Jan-Erik, I will try the relocatable mode. Have not done this before...


----- Original Message ----- From: "Jan-Erik Soderholm" <spam_OUTjan-erik.soderholmTakeThisOuTspamtelia.com>
To: "Microcontroller discussion list - Public." <.....piclistKILLspamspam@spam@mit.edu>
Sent: Saturday, March 03, 2012 7:47 PM
Subject: Re: [PIC] Test and Set/Clear bit in Bank 1


{Quote hidden}

> -

2012\03\05@111019 by Jan-Erik Soderholm

face picon face
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 removed}

More... (looser matching)
- Last day of these posts
- In 2012 , 2013 only
- Today
- New search...