Searching \ for 'rotate' 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/index.htm?key=rotate
Search entire site for: 'rotate'.

Truncated match.
PICList Thread
'Rotate'
1997\07\10@044345 by David BALDWIN

flavicon
face
I am trying to rotate one byte into another, can somebody tell me if
the following is right?


       movlw 0x08
       movwf count
loop    bcf   status, carry
       rrf   Byte1,1
       rrf   Byte2,1
       decfsz count
       goto loop

Thanks,

David

1997\07\10@053129 by Clewer,Brian

flavicon
face
>I am trying to rotate one byte into another, can somebody tell me if
>the following is right?
>
>
>       movlw 0x08
>        movwf count
>loop    bcf   status, carry
>        rrf   Byte1,1
>        rrf   Byte2,1
>        decfsz count
>        goto loop
>
>Thanks,
>
>David


David, as the whole principle of this works on the carry in the status
register,  I think you need a  ' BCF    STATUS,C '   after the ' RRF
  Byte2,1' instruction to clear the carry.  It should work then (not
tested).

Brian.

1997\07\10@053958 by David BALDWIN

flavicon
face
Brian, the first line of the loop is BCF STATUS,CARRY, it is sufficient,
no?

David

1997\07\10@061352 by Kieran Sullivan

flavicon
face
Your routine should work as it is. It will set Byte1 to all 0's and Byte2
will be equal to whatever was in Byte1 when you started...There is probably
a better way of doing this copy, but I am sure you have your reasons.
Unless you really want to do a rotate you could use:

       movf    Byte1, w
       movwf   Byte2
       clrf    Byte1

Kieran.

P.S. Sorry for including all the original mesage, but I suspect that if I
edit even a small part of it, my MSMail will scramble the entire message.

----------
From:   Clewer,Brian[SMTP:spam_OUTbrian.clewerTakeThisOuTspamTELEMATICS.COM]
Sent:   10 July 1997 18:36
To:     .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
Subject:        Re: rotate

{Quote hidden}

David, as the whole principle of this works on the carry in the status
register,  I think you need a  ' BCF    STATUS,C '   after the ' RRF
  Byte2,1' instruction to clear the carry.  It should work then (not
tested).

Brian.

1997\07\10@063433 by David BALDWIN

flavicon
face
Thanks to all who replied. Kieran, in fact, I need to rotate, its a
reception of 12 bytes from TLC2543 ADC (a great part to work with PICs!)

Bye

David

1997\07\11@100604 by Tom Handley

picon face
re: Reading a 12 Bit A/D

  David, I've always been hesitant to post code in this group because I use
the Parallax assembler with 805x syntax and the code is usually `snipped'
from an application that I've done and may not be optimized for other apps.
Anyway, here is a `snippet' of code that I use to talk with a Maxim 186
12-Bit A/D with an 8-channel mux. It reads a variety of sensors and has been
working fine for over a year. The conversion to Microchip's syntax should be
easy. Note, I'm using a 16C74A with an external data bus and a 74HCT138
address decoder (BCS). I also talk to a variety of serial devices so I use a
separate routine to pulse SCLK. Ignore the "!CS" stuff as you would have to
see the overall design to make sense out of it. Basically, I send a control
byte (in another routine) and read the 4 MSBs, then the 8 LSBs in 2
variables.

  - Tom

--------
; Read A/D Converter
; Entry:
;   serdata = Control Byte/Channel Select
; Exit:
;   Temp16L = LSB (Lower 8 Bits, B0-B7)
;   Temp16H = MSB (Upper 4 Bits, B8-B11)

Read_ADC
       AND     RB,#CSMASK              ; Set A/D CS Address Mask
       OR      RB,#ADCS
       CLRB    BCS                     ; Set !CS Low
       CALL    Send_Data               ; Send Control Byte
       SETB    BCS                     ; Set !CS High
       CLR     Temp16L                 ; Clear Temp 16 Bit register LSB
       CLR     Temp16H                 ; Clear Temp 16 Bit register MSB
:loop1  JNB     ADBUSY,:loop1           ; Wait for Conversion
       MOV     bcount,#4               ; Set Bit counter for 4 Bits
       CLRB    BCS                     ; Set !CS Low
:loop2  CALL    SCLKP                   ; Pulse SCLK
       MOVB    C,SDI                   ; Put MSB Bit in Carry
       RL      Temp16H                 ; Rotate Carry into data buffer
       DJNZ    bcount,:loop2           ; If not 4 Bits, get another
       MOV     bcount,#8               ; Set Bit counter for 8 Bits
:loop3  CALL    SCLKP                   ; Pulse SCLK
       MOVB    C,SDI                   ; Put MSB Bit in Carry
       RL      Temp16L                 ; Rotate Carry into data buffer
       DJNZ    bcount,:loop3           ; If not 8 Bits, get another
       SETB    BCS                     ; Set !CS High
       RET



At 12:29 PM 7/10/97 +0200, you wrote:
>Thanks to all who replied. Kieran, in fact, I need to rotate, its a
>reception of 12 bytes from TLC2543 ADC (a great part to work with PICs!)
>
>Bye
>
>David

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