How to read data 4 bit


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2005
    Posts
    70

    Talking How to read data 4 bit

    I would to read last 4 bit of data.
    Ex:
    Data = FA ' hex

    4bit.low = 10 'Dec
    4bit.high = 15 'Dec
    Last edited by chai98a; - 10th December 2006 at 04:29.

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    4BitLo = Data & $0F ' = 10
    4BitHi = Data >> 4 ' = 15

    (See manual or online for & and >> details)
    Last edited by paul borgmeier; - 10th December 2006 at 05:27.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    May 2005
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Thank you paul borgmeier
    I have 1 question...
    How to convert Hex to Dec?

    we try to do 7seg display time.
    If we need to show minute 10 , sec 20

    n = Value Dig i ' Get digit to display

    So, how to store data minute and sec in to Value = 2010 (dec)
    Last edited by chai98a; - 10th December 2006 at 15:06.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    where the data comes from?

    anyways, the following should work
    Code:
        '
        '   HEX to DEC
        '   ----------
        Decimal=((Hexadecimal>>4)*10)+(Hexadecimal & $0F)
    
        '
        '   DEC to HEX
        '   ----------
        Hexadecimal=((Decimal/10)<<4)+(Decimal // 10)
    Last edited by mister_e; - 10th December 2006 at 19:24.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Chai98a,

    If you have enough RAM, it is easier to keep the seconds, minutes, hours, etc., all in their own variable. This saves building and unbuilding combined variables each time a second passes. I have posted two examples of clocks here

    http://www.picbasic.co.uk/forum/showthread.php?t=2129

    that uses separate variables for each “item”. The code sections of interest for you are at the very end of the programs. The first only has minutes and hours but seconds could easily be added. The second has all three. Check them out and see if they might help.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  3. AT/PS2 Keybord - PIC Interface?
    By Kamikaze47 in forum Code Examples
    Replies: 73
    Last Post: - 9th August 2009, 16:10
  4. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  5. MAX1247 4-Channel, 12-Bit ADC
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 15th December 2006, 23:38

Members who have read this thread : 1

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