Searching \ for ' bit adjustment' 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=bit+adjustment
Search entire site for: 'bit adjustment'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] bit adjustment'
2001\05\01@122743 by Elopes

picon face
Hi  PIClisters !

I've been learning a lot with you reading your posts. by now I have a
trouble that I can't solve by myself, please can

I'm writing a code to a remote control system with 4 channels, where the
variable "channel" represents the "bit" that must be changed on PORTB. There
is my code:

;channel assumes values from 0 to 3
   movf    portb, w          ; make a copy of portB
   movwf    sendreg        ; on sendreg register
       "
       "
       " do something
       "
   btfss      sendreg, channel
   goto      _set                          ; this should invert the bit
                                                   ;"channel"
   bcf        sendreg, channel       ; on sendreg  register  ====> but it
                                               ;doesn't do that !!!
   goto      $ + 2
_set
   bsf       sendreg, channel
   movf    sendreg, w
   movwf    portb
   return

the instruction < bsf  register, b > only accepts a literal on "b"???
how can I set a bit on a register (sendreg) using another pointer register
(channel)???
any suggestions?
thanks in advance,
Eduardo.

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\05\01@130118 by Bob Ammerman

picon face
> Hi  PIClisters !
>
> I've been learning a lot with you reading your posts. by now I have a
> trouble that I can't solve by myself, please can
>
> I'm writing a code to a remote control system with 4 channels, where the
> variable "channel" represents the "bit" that must be changed on PORTB.

The BSF, BCF, BTFSS and BTFSC instructions do only accept a literal for the
bit number.

So, you have to use logical instructions instead:

First, you'll need a subroutine to convert from a channel number to a
channel mask. This can be done as a lookup table or via direct logic.

get_channel_mask:
   movf    channel,W
   addwf  PCL,F
   retlw    1        ; channel 0
   retlw    2        ; channel 1
   retlw    4        ; channel 2
   retlw    8        ; channel 3

(standards warnings about setting PCLATH and spanning page boundaries apply
to the above routine).

Now: to set a PORTB bit for a channel:

   call    get_channel_mask
   iorwf    PORTB,F

To clear a PORTB bit for a channel:

   call    get_channel_mask
   xorlw    0xFF
   andwf    PORTB,F

To see if a bit is set for a channel:

   call    get_channel_mask
   andwf    PORTB,W
   skpz -- or-- skpnz

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\05\01@190712 by Eduardo Lopes

picon face
Sorry, I forgot the topic tag.
----- Original Message -----
From: Elopes <elopes_74spamKILLspamhotmail.com>
To: pic microcontroller discussion list <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU>
Sent: Tuesday, May 01, 2001 1:25 PM
Subject: bit adjustment


> Hi  PIClisters !
>
> I've been learning a lot with you reading your posts. by now I have a
> trouble that I can't solve by myself, please can
>
> I'm writing a code to a remote control system with 4 channels, where the
> variable "channel" represents the "bit" that must be changed on PORTB.
There
{Quote hidden}

register
> (channel)???
> any suggestions?
> thanks in advance,
> Eduardo.
>
>
>

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


'[PIC]: Re: bit adjustment'
2001\05\01@191734 by Eduardo Lopes

picon face
Thanks Bob Ammerman.
You help me a lot. See how I coded the program:

    clrf acionador    ;string to AND with portB
    movf canal, w
    movwf valor            ;a channel copy
    movwf contador     ; set the counter
    bsf status, c
    rlf acionador, f        ; rotates the control word
    decfsz contador
    goto $ - 2
    movf sendreg, w
    andwf acionador, w    ;verify if the channel is on low or high level
    btfsc status, z
    goto _seta                    ; go to the set routine
    comf acionador, w
    andwf sendreg, w        ;clear bit
    call ser_out                ;put the value on portb
    return
_seta
    movf acionador, w        ;set bit
    iorwf sendreg, w
    call ser_out                    ;put the value on portb
    return

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


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