toggling bits


Closed Thread
Results 1 to 3 of 3

Thread: toggling bits

  1. #1

    Default toggling bits

    Hello Everyone,
    If I send the value of a variable out ,
    SEROUT SerPin,N2400,[PreAmble,Synch,PORTB]' sending Pic
    and I receive it,
    SERIN serpin,N2400,[9],PORTB' on the receiving Pic
    PORTB.0 if it is a 1, I want PORTB.0 on the receiving Pic to stay a 1 and all of the other bits to be the rest of what it received so I can set PORTB. I would like PORTB.0 to remain High until it received another 1 on bit0. In this way I can keep a master relay on and PORTB bits 1-7 will change state as the data is received. If PORTB is my variable, and I create a another variable, car var PORTB.0 Will everytime PORTB is received does the value of car change its value or can I hold car value until PORTB.0 =1? So if PORTB.0 becomes a 1 again I want the value of car to be 0 so I can turn off the relay. Thanks

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    If I understood the question correctly, this might work ...
    Code:
    RXchar  VAR BYTE
    
    SERIN serpin,N2400,[9], RXchar
    
    IF RXchar.0 = 1 THEN TOGGLE PORTB.0
    PORTB = (PORTB & 1) | (RXchar & $FE)
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    I will give it a try, Thank you!!

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  3. PIC's ports individual bits manipulation - how to?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 38
    Last Post: - 27th February 2007, 22:34
  4. Need clever way to convert 10 bits to 8 bits
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd September 2005, 15:13
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts