Loading data into ONLY 4 bits of a port - is it possible?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Loading data into ONLY 4 bits of a port - is it possible?

    The standard way to do this is read-modify-write. To change lower 4 bits only, read all 8 bits, strip off lower 4 bits, add your new value, then write 8 bits back. To change upper 4 bits only is more complicated, but also doable (hint - use shift left / shift right). Still, this is unnecessarily complicated for what you want to do... just do it bit by bit. Place the code in a subroutine and call it to read/write your values for simplicity - use it like a new command.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Loading data into ONLY 4 bits of a port - is it possible?

    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Assign different port bits to an array?
    By vamtbrider in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th November 2010, 03:40
  2. loading data to EXt. eeprom
    By MINHLE in forum General
    Replies: 0
    Last Post: - 28th December 2009, 18:56
  3. Serin2 data bits
    By Luckyborg in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th February 2009, 23:10
  4. 16F88 7 data bits
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 17th February 2008, 02:05
  5. pre loading eeprom data
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th April 2004, 12:18

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