Unable to use the number 8 in DATA statement


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2008
    Posts
    52

    Default Unable to use the number 8 in DATA statement

    Whenever I run this in my 18F1320, I can read the data statement just fine but in place of 8's there are 3's. If I put in any other number it seems to work fine. I don't get it.

    Thanks, Don

    Code:
    ' Define LCD pins
    Define  LCD_DREG        PORTA
    Define  LCD_DBIT        0
    Define  LCD_RSREG       PORTA
    Define  LCD_RSBIT       4
    Define  LCD_EREG        PORTB
    Define  LCD_EBIT        3
    
    OSCCON = $60 ' Set up internal oscillator
    x var byte
    dtmf var byte
    data @1,1,3,0,8,8,6,0,7,3,7,5
    TRISB = %11010000
    TRISA = %01100000
    Pause 500 ' Wait 500mS for LCD to startup
    LCDOut $fe, 1 ' Clear LCD screen
    Pause 1 ' Wait 1 millisecond
    LCDOut $fe,$80 ' Move cursor to the beginning of the first line
    LCDOut "DTMF Demo using" ' Display
    LCDOut $fe,$c0 ' Move cursor to the beginning of the second line
    LCDOut "PIC18F1320" 'Display PIC Lecture
    pause 1000
    LCDOut $fe, 1 ' Clear LCD screen
    LCDOut $fe,$80 ' Move cursor to the beginning of the first line
    loop:
          
      for x = 1 to 11
            read x, dtmf
            portb = dtmf
            low portb.5
            pause 100
            high portb.5
            pause 100
            LCDOut DEC1(dtmf)
      next x
            pause 200
            LCDOut $fe, 1 ' Clear LCD screen
            pause 100
            goto loop ' Do it forever
            
            End

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    A couple things...

    You're writing the dtmf value to all 8 bit's of PORTB. But PORTB.3 is the LCD's Enable Bit.
    So when the data is 8, PORTB.3 gets set High, interfering with the enable line.

    You should also turn off the Analog functions since the LCD is on PORTA.
    ADCON1 = $7F
    <br>
    DT

  3. #3
    Join Date
    Oct 2008
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel,

    Kind of makes sense now that you point out the obvious. Every little bit helps in the learning process though.

    Don

  4. #4
    Join Date
    Oct 2008
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    How do I just write to the 4 bits I am using?
    Last edited by dbachman; - 7th December 2008 at 01:23.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dbachman View Post
    Hi Darrel,

    How do I just write to the 4 bits I am using?
    Hi Don,
    PortB.3 is in the lower 4 bits you are using, you might think good thoughts of moving the E bit to b.4 and then you can address the lower bits as individuals or read the entire port and mask out the upper bits after reading them.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Oct 2008
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hi Joe,

    I did do something like that. I moved it to Porta bit 7. Just sittin there anyway. How do you read the entire port - better yet, how would you masked out the bits. I am still in a steep learning curve so please bear with me. Is it like this?

    DTMF = DTMF & %00001111 ' isolate lower 4 bits

    Thanks, Don
    Last edited by dbachman; - 7th December 2008 at 04:06.

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Last edited by Archangel; - 7th December 2008 at 06:38.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Nokia 3310 display text
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th August 2007, 03:39
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23: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