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.

Shift PORTA left, not possible?

Status
Not open for further replies.

zanor

Member level 4
Joined
Feb 17, 2006
Messages
79
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Norway
Activity points
2,039
Hi!

I'm using 16F648 and trying to shift PORTA to left but when I use:

RLF PORTA, F

Then it's just blanked out, same with RRF.
I have checked this on chip and with step by step on emulator.

Before I do this I put 0x01 to PORTA.

Is this normal?
 

I assume you have PORTA configured as digital. You may be experiencing one or more problems. First, Port A on the '648 cannot be configured as 8 outputs (RA5/MCLR can only be an input). Second, you may be experiencing the RMW (Read/Modify/Write) problem documented in numerous articles at Microchip, PICLIST, and elsewhere.

You might consider experimenting with Port B instead of Port A. Set PORTB as all outputs. Rotate Port B with W as the destination then write W to Port B. Use a couple NOP instructions between the two instructions if the data isn't sticking because of RMW problems.

Good luck with your project. Regards, Mike

Code:
;
        rlf     PORTB,W         ; rotate left PORTB, result in W    |B0
        nop                     ;                                   |B0
        movwf   PORTB           ; save rotated data back to PORTB   |B0
;
 

Mike said:
First, Port A on the '648 cannot be configured as 8 outputs (RA5/MCLR can only be an input).

And not only that, unimplemented bits read as zero. Bit 7, 6 etc will always be zero, and rotate into carry then back into bit 0..

Code:
clrc
btfsc  porta,x
setc
rlf      porta,f

Where 'x' is the highest bit that is really there. You move it manually into carry first, then finish the rotate. Or rotate in normal ram, then copy over to porta.

Alan
 

Hi
Note, the input pin of portA will not change value even after rotation
 

Alan69 said:
And not only that, unimplemented bits read as zero. Bit 7, 6 etc will always be zero, and rotate into carry then back into bit 0..

Alan, RA6 and RA7 on the '627/'628/'648 devices can be configured as I/O using one of the INTOSC options in the config' fuses. So, as I mentioned earlier, the only potential problem with PORTA is the RA5/MCLR pin which can only be configured as an input.

Regards, Mike
 

Thanks for all your help!

Since this seems to be problem with this chip I have decided to look at other method's for what I'm trying to do.
 

Mike said:
Alan69 said:
And not only that, unimplemented bits read as zero. Bit 7, 6 etc will always be zero, and rotate into carry then back into bit 0..

Alan, RA6 and RA7 on the '627/'628/'648 devices can be configured as I/O using one of the INTOSC options in the config' fuses. So, as I mentioned earlier, the only potential problem with PORTA is the RA5/MCLR pin which can only be configured as an input.

Regards, Mike

Ah duh of course you are correct, I likely pulled up the 87x data from worn habit..
 

Alan69 said:
Mike said:
Alan69 said:
And not only that, unimplemented bits read as zero. Bit 7, 6 etc will always be zero, and rotate into carry then back into bit 0..

Alan, RA6 and RA7 on the '627/'628/'648 devices can be configured as I/O using one of the INTOSC options in the config' fuses. So, as I mentioned earlier, the only potential problem with PORTA is the RA5/MCLR pin which can only be configured as an input.

Regards, Mike

Ah duh of course you are correct, I likely pulled up the 87x data from worn habit..

You mean you don't have them all memorized (grin)?

Take care. Kind regards, Mike
 

Hi All

I suggest using the MChip recommended method of modifying port data avoiding the use of read-modify-write instructions on the ports, - namely using a port shadow register on which operations are performed then the result is written (copied) to the port as a full byte. This is the recommended method for electrically noisy environments.

regards ... Polymath
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top