BCD to 7-segment issues


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Oct 2011
    Posts
    54


    Did you find this post helpful? Yes | No

    Default Re: BCD to 7-segment issues

    Let us suppose bits 5 and 6 of portb are set and 4 is displayed on the 7 seg display and we want to display 5
    portb will be %01100100
    (portb & $F0) will clear the lower 4 bits of portb leaving bits 5 and 6 unchanged.

    01100100 &
    11110000
    ========
    01100000 result A

    (mybyte & $0F) will clear the top 4 bits of mybyte
    11000101 &
    00001111
    ========
    00000101 result B

    we now OR ( | ) result A with result B

    01100000 OR
    00000101
    ========
    01100101

    Bits 5and 6 of portb are unchanged and the lower 4 bits are set to 5
    If mybyte is never going to be greater than 9, (mybyte & $0F) can be replaced by mybyte

    See bitwise operators in the manual

  2. #2
    Join Date
    Feb 2013
    Posts
    1,160


    Did you find this post helpful? Yes | No

    Default Re: BCD to 7-segment issues

    Thanks! So it is logical operation with pre-defined masks.

Similar Threads

  1. Replies: 4
    Last Post: - 2nd November 2012, 10:47
  2. Multiplexing 7-Segment
    By ross246 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th June 2011, 23:31
  3. Seven Segment LED
    By Brian in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 5th May 2011, 05:26
  4. interupt with 7-segment
    By freqout in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th February 2010, 10:06
  5. keypad + 7-segment
    By evmav in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th June 2006, 20:40

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