4 bit bus


Closed Thread
Results 1 to 4 of 4

Thread: 4 bit bus

  1. #1
    Join Date
    Aug 2003
    Posts
    985

    Default 4 bit bus

    Hi Guys,
    Is it possible to set the first four bits on a port in one line without
    writing to the rest of the port? I was wondering how the LCD 4 bit bus mode works.

    I could send %1111 to porta for example, but then porta bits 4-7 would be
    written with zeros.

    I'm looking for something better than setting the bits individually.
    Cheers, Art.

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Art, Tray:

    PortA = PortA & %00001111

    Al.
    All progress began with an idea

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    PortA = PortA & %00001111 would only work if the lower 4-bits were already set,
    and would guarantee the higher 4-bits would be 0.

    You want to OR the port with %00001111 to leave the higher 4-bits unaffected.

    PortA = PortA | %00001111 would set the lower 4-bits, leaving the higher 4-bits
    as-is.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    PortA = PortA & %00001111 would only work if the lower 4-bits were already set,
    and would guarantee the higher 4-bits would be 0.

    You want to OR the port with %00001111 to leave the higher 4-bits unaffected.

    PortA = PortA | %00001111 would set the lower 4-bits, leaving the higher 4-bits
    as-is.
    Seems to be working thanks

    Saves two words on setting the four bits one at a time.

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. 4 or 8 bit LCD data bus (HD44780)
    By sumkrnboy in forum General
    Replies: 1
    Last Post: - 10th May 2008, 21:05
  3. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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