Confused On Dig & Lookup


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2006
    Location
    WADSWORTH OHIO USA
    Posts
    37

    Unhappy Confused On Dig & Lookup

    Greetings !! As Usual I'm In Search Of Answers,
    We're Using A Pic16f870 Using The Following Code:

    DEFINE OSC 20 'DEFINE OSCILLATOR
    DEFINE SER2_BITS 8

    AS VAR BYTE 'DEFINE VARIABLES
    D VAR BYTE
    F VAR BYTE
    N VAR BYTE
    S VAR BYTE
    T VAR BYTE
    I VAR BYTE
    A VAR BYTE
    B VAR BYTE
    K VAR BYTE
    E VAR BYTE

    'EQUATES SECTION
    TRISA = %00111110 'SET PORTS I/O
    TRISB = %00000000
    TRISC = %00000000
    ADCON0 = %00000000
    ADCON1 = %00000011 'PORTA ALL DIGITAL

    A = 123 'INITIATE VARIABLES
    AS = 0 'FOR TEST RUN
    D = 0
    F = 200
    N = 0
    T = 1234
    S = 0
    A = 0
    B = 0
    I = 0
    K = 0


    'IT ALL STARTS HERE

    PAUSE F

    LOOP: 'GET T&C FROM PIC7

    'IF PORTA.4 = 1 THEN
    'SERIN2 PORTA.0 \ PORTA.1, 396, [T, A]
    AS = A * 10
    ENDIF

    LOOP1: '8 DIGITS TO DISPLAY T & A

    FOR E = 0 TO 3
    PAUSE F 'DISPLAY T =1234
    LOOKUP T DIG E,[$41,$F3,$49,$61,$33,$25,$05,$F1,$01,$31], PORTB
    LOOKUP E,[$EF,$DF,$BF,$7F],PORTC 'SET DIGIT
    PAUSE F
    PORTC = $FF
    NEXT E

    FOR B = 0 TO 3
    PAUSE F 'DISPLAY A =5678
    LOOKUP AS DIG B,[$41,$F3,$49,$61,$33,$25,$05,$F1,$01,$31], PORTB
    LOOKUP B,[$F7,$FB,$FD,$FE],PORTC
    PAUSE F
    PORTC = $FF
    NEXT B
    PAUSE F
    GOTO LOOP ' DISPLAY FOREVER


    The First Lookup To Grab The Digit And Convert It To Segments
    The Next Lookup Grabs Digit Placement
    Placement Works Briliantly Over The Eight Digits But Am Unable To
    Grab The Individual Digits
    Could Someone Please Point Out The Obvious For Me?
    Thanks!!
    Last edited by SOMRU; - 5th December 2006 at 19:01. Reason: RECODED

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    I guess, there is a variable named "A", but now shown in your code here.

    So in the second FOR LOOP, there should be "N = A Dig B".

    But, even then, I did not understand what you meant by individual digits? individual digits of which variable? Can you be more specific and give example?


    Also, I have some modifications and suggestions as below. I removed some parts to make it work faster and seem easier to understand.

    Code:
    A VAR BYTE 'this was not listed!
    E VAR BYTE
    F VAR BYTE
    N VAR BYTE
    D VAR BYTE
    S VAR BYTE
    B VAR BYTE
    T VAR BYTE
    
    
    
    Loop1: '8 Digits To Display T & A
    
    
    For E = 0 To 3
    
            Pause F 'display T =1234
    
            Lookup T DIG E,[$41,$f3,$49,$61,$33,$25,$05,$f1,$01,$31], PORTB '0-9
    
            Lookup E,[$ef,$df,$bf,$7f], PORTC 'set Digit
    
            Pause F
    
            PORTC = $ff
    
        Next E
    
    
        For B = 0 To 3
            Pause F 'display A =5678
    
            Lookup A DIG B,[$41,$f3,$49,$61,$33,$25,$05,$f1,$01,$31],PORTB
    
            Lookup B,[$f7,$fb,$fd,$fe],PORTC
    
            Pause F
    
            PORTC = $ff
    
        Next B
    
    Pause F
    
    Goto Loop1 ' Display Forever


    Edit: 'Also, if you store these numbers in EEPROM, then you can just use the following.
    ' could work even faster, and use less code space.

    'Example: READ T DIG E, PORTB


    ------------------------
    Last edited by sayzer; - 5th December 2006 at 17:55.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Dec 2006
    Location
    WADSWORTH OHIO USA
    Posts
    37


    Did you find this post helpful? Yes | No

    Talking Second Sight

    FOUNDIT! FOUNDIT!

    I was trying to disassemble a byte instead of a word !

    Requalified var A as a word and all is now well.

    Thank all for their help.

    Sometimes it takes a second set of eyes.


    SOMRU
    Thanks !
    SOMRU
    TWE/TFP/EE

Similar Threads

  1. NMEA CheckSum Routine
    By Tom Gonser in forum Code Examples
    Replies: 2
    Last Post: - 6th June 2015, 22:24
  2. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  3. DIG DEC Madness
    By earltyso in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th June 2008, 23:05
  4. Rc int on 16f874
    By hakan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th July 2007, 18:57
  5. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56

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