righteous
Full Member level 2
Gents,
My objective is simply to read bits 2:0 on PORTB and AND it with a bit mask, but the AND operation always yields 0x07 regardless of PORTB value. It's just one of those things that makes me stupider the longer I try to solve it. Anyway here's my environment:
MCU: PIC16F1933
Product Version: MPLAB X IDE v4.15
Java: 1.8.0_144; Java HotSpot(TM) 64-Bit Server VM 25.144-b01
Runtime: Java(TM) SE Runtime Environment 1.8.0_144-b01
System: Linux version 4.13.0-36-generic running on amd64; UTF-8; en_US (mplab)
Compiler: mpasm(v5.77)
Currently loaded firmware on PICkit 3
Firmware Suite Version.....01.51.08
Firmware type..............Enhanced Midrange
And here is the code:
I added a watch for WREG in the IDE to monitor W register. But it's always 0x07 regardless of PORTB value, what is wrong here?
My objective is simply to read bits 2:0 on PORTB and AND it with a bit mask, but the AND operation always yields 0x07 regardless of PORTB value. It's just one of those things that makes me stupider the longer I try to solve it. Anyway here's my environment:
MCU: PIC16F1933
Product Version: MPLAB X IDE v4.15
Java: 1.8.0_144; Java HotSpot(TM) 64-Bit Server VM 25.144-b01
Runtime: Java(TM) SE Runtime Environment 1.8.0_144-b01
System: Linux version 4.13.0-36-generic running on amd64; UTF-8; en_US (mplab)
Compiler: mpasm(v5.77)
Currently loaded firmware on PICkit 3
Firmware Suite Version.....01.51.08
Firmware type..............Enhanced Midrange
And here is the code:
Code:
movlw 0x07 ; sensor mask, retain only the sensor bits
andwf PORTB,W ; get sensor data, AND it with W and store result in W
I added a watch for WREG in the IDE to monitor W register. But it's always 0x07 regardless of PORTB value, what is wrong here?