Changing several o/p pins at the same time


Results 1 to 11 of 11

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Read-Modify-Write, just like the chip does it when setting a single bit.

    Code:
    PORTB = (PORTB & %11110000) | MyNibble
    This reads the Port, saves the bits you don't want to change, then adds the new bits and writes it back to the Port.

    If there's any possibilty of bits above 3 being set in the MyNibble variable, you should use this instead ...
    Code:
    PORTB = (PORTB & %11110000) | (MyNibble & %00001111)
    <br>
    Last edited by Darrel Taylor; - 1st August 2008 at 20:30. Reason: Rat's, ya beat me ski. :(
    DT

Similar Threads

  1. Change On Interrupt, PIC16F884
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 14th November 2008, 17:25
  2. I don't understand this code!
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 13th February 2008, 02:55
  3. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  4. Control unlimited servos at the same time
    By mrx23 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th September 2006, 14:14
  5. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 14:24

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