Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to change two bits from a byte in the same step?

Status
Not open for further replies.

laser

Junior Member level 3
Joined
Sep 26, 2001
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
212
Dear friends:
I´m working on an assembler program for a mid range PICmicro MCU, with wich I need to generate several signals simultanously.
At a certain step, I will need to simultaneously change (set or reset) the state of two bits from a PORT register, keeping all the others unchanged, and the two bit values might be diferent from each other.
BSF and BCF canot be used, because if used, the bit changes will happen in two diferent steps.
Anyone knows any short bitwise operation to do this?

Thanks alot for any help.

Francisco S.
 

Francisco,
use XOR, i.e,
movlw b'00000011' //11 is port bits to change
xorfw PORT

if PORT xxxxxx11 becomes xxxxxx00
if PORT xxxxxx10 becomes xxxxxx01
if PORT xxxxxx01 becomes xxxxxx10
if PORT xxxxxx00 becomes xxxxxx11
 

Be careful when doing this because of possible "read modify write" issues inside the pic processors.

Read here about this effect:
**broken link removed**

best regards
 

If above is an issue, then

movfw PORT ; PORT value to W
movwf TEMP ; save it to TEMP
bsf or bcf TEMP,bit# ; change as needed
bsf or bcf TEMP, bit# ; change as needed
movfw TEMP ; move TEMP to W
movwf PORT ; move W to PORT
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top