Pic16f57 + lcdout=error


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2009
    Posts
    737

    Question Pic16f57 + lcdout=error

    When I try to compile I get this:
    Code:
    ERROR: Macro LCDOUTCOUNT?C not found in macro file.
    ERROR: Macro LCDOUTNUM?W not found in macro file.
    ERROR: Macro LCDOUTDEC? not found in macro file.
    All Done, PCB, soldering. Project must be finished tomorow
    Does anybody know why this happens and how to solve this problem?
    I'm using PBP 2.60A & MCS 4.0
    Is there any hope for this project to be completed on time?
    Last edited by pedja089; - 6th October 2010 at 18:57.

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Can you give any more information? I put a simple lcdout command in pbp 2.60a for a 16F57 (MCS 3.0.0.5), and just got a crossing page boundary warning. No errors.

    There is always hope.....
    Last edited by ScaleRobotics; - 6th October 2010 at 19:40.
    http://www.scalerobotics.com

  3. #3
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default

    Yes of course.
    All comments are in Serbian.
    Programm:
    Code:
    '@ DEVICE XT_OSC,WDT_OFF,PROTECT_ON
    'DEFINE LCD_BITS 4
    'DEFINE LCD_DREG PORTB
    'DEFINE LCD_DBIT 0
    'DEFINE LCD_RSREG PORTB
    'DEFINE LCD_RSBIT 4
    'DEFINE LCD_EREG PORTB
    'DEFINE LCD_EBIT 5
    'DEFINE LCD_LINES 2
    
    DEFINE LCD_BITS 4
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTA
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTA
    DEFINE LCD_EBIT 3
    DEFINE LCD_LINES 2    
        Tz var word
        Tt Var Word         
        Set var byte        
        Ton var byte
        Toff var byte
        Mode var byte
     
        CR Var Byte         
             
        
        Sn var byte
        Ss var byte
        
        Znak1 var byte
        Znak2 var byte
        Znak3 var byte
        Znak4 var byte
    
        I var byte
        
        symbol DQ = portb.4          
        symbol Tmode= portb.5
        symbol Tp=portb.6
        symbol Tm=portb.7
        symbol Rele=porta.1
        
        SYMBOL SCL = portc.4     
        SYMBOL SDA = portc.5
        
        input tmode
        input tp
        input tm
        output rele
        'adcon1=7
        clear
    ss = tm         
    rele=0
    set=0
    i=0
    pause 100
    lcdout $fe,1, " ....."
    Lcdout $fe, $C0," www.....hr"
    pause 2000
    I2Cread SDA,SCL,$A0,0,[tz.lowbyte,tz.highbyte,toff,ton]
    if tz>600 then tz=200
    if toff=>100 then toff=5
    if ton=>100 or ton=0 then ton=5
    
    Pocetak:
    sn = tmode
     if sn<ss then  set= set + 1
        
      if set>3 then 
       set = 0
      endif 
           
    ss=sn
    select case set
        CASE 0
         znak1=" "
         znak2=" "     
         znak3=" "
         call izmeri
         i=0  
        
        CASE 1 
         znak1=">"
         znak2=" " 
         znak3=" "
         if tp=0 and tz<600 then 
          tz=tz+5
          i=0
         endif 
         if tm=0 and tz=>5 then 
          tz=tz-5 
          i=0  
         endif
          I2CWrite SDA,SCL,$A0,0,[tz.lowbyte,tz.highbyte]
        
        CASE 2
         znak1=" "
         znak2=">"
         znak3=" "
         if tp=0 and ton<100 then 
          ton=ton+5
          i=0
         endif 
         if tm=0 and ton=>5 then 
          ton=ton-5
          if Ton=0 and toff=0 then ton=5
          i=0  
         endif
         I2CWrite SDA,SCL,$A0,3,[ton]
         
        CASE 3 
         znak1=" "
         znak2=" " 
         znak3=">"
         if tp=0 and toff<100 then 
          toff=toff+5
          i=0
         endif 
         if tm=0 and toff=>5 then
          toff=toff-5 
          if Ton=0 and toff=0 then toff=5
          i=0  
         endif
         I2CWrite SDA,SCL,$A0,2,[toff]
         
    END SELECT 
    
     if tz+ton<=tt and set=0 and znak4="+" then 'ako je zadata temp manja od trenutne 
      rele=1                    'ukljuci rele
     endif                      
     if (tz=>toff and tz-toff=>tt and znak4="+") or (tz<toff and toff-tz<=tt and znak4="-" ) or set>0 then             'ako je zadata temperatura veca od trenutne ili si usao u meni
      rele=0
     endif
     
       
     i=i+1
     if i >100 then set = 4 'izadji iz menija
    
    call prikazi
    pause 150
    goto pocetak
    
    
    
    
    
    Prikazi:           
           Lcdout $fe,1,znak1,"+",DEC2 (tz / 10), ".",#(tz dig 0),223, "C"
           if set=0 then lcdout $fe,$89,znak4,DEC2 (tt / 10), ".",#(tt dig 0) ,223, "C" '178
           Lcdout $fe, $C0, znak2,"+",DEC2 (ton / 10), ".",#(ton dig 0),223, "C",znak3,"-",DEC2 (toff / 10), ".",#(toff dig 0),223, "C"        
    return
    
    Izmeri:
    
     OWOut DQ, 1, [$CC, $44]      ' Start merenja temperature
     Cekaj:    OWIn DQ, 4, [cr]     ' Provera da li jos traje
            If cr = 0 Then Cekaj
            
            OWOut DQ, 1, [$CC, $BE]      ' Procitaj izmerenu temperaturu
            OWIn DQ, 0, [tt.LOWBYTE, tt.HIGHBYTE]', Skip 4, cr, cpc]
            
            If tt.bit15=1 then
             znak4="-"
             tt = abs(tt)
            else
             znak4="+"
            endif
            tt=(tt>>1)*10+tt.0*5        
    return
    It's simple thermostat with hysteresis.
    I tested it on easypic5 and PIC16F877, everything works great,but when I tried to compile for the PIC16F57, I got errors...
    When I remove LCDOUT comands, then I get this:
    Code:
    Called Adresses must Reside in Lower Half of Page
    I tried to reorganize the code, remove LCDOUT, but then i get an error when using I2C commands...
    Code:
    '@ DEVICE XT_OSC,WDT_OFF,PROTECT_ON
    'DEFINE LCD_BITS 4
    'DEFINE LCD_DREG PORTB
    'DEFINE LCD_DBIT 0
    'DEFINE LCD_RSREG PORTB
    'DEFINE LCD_RSBIT 4
    'DEFINE LCD_EREG PORTB
    'DEFINE LCD_EBIT 5
    'DEFINE LCD_LINES 2
    
    DEFINE LCD_BITS 4
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTA
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTA
    DEFINE LCD_EBIT 3
    DEFINE LCD_LINES 2    
        Tz var word
        Tt Var Word         
        Set var byte        
        Ton var byte
        Toff var byte
        Mode var byte
     
        CR Var Byte         
             
        
        Sn var byte
        Ss var byte
        
        Znak1 var byte
        Znak2 var byte
        Znak3 var byte
        Znak4 var byte
    
        I var byte
        
        symbol DQ = portb.4          
        symbol Tmode= portb.5
        symbol Tp=portb.6
        symbol Tm=portb.7
        symbol Rele=porta.1
        
        SYMBOL SCL = portc.4     
        SYMBOL SDA = portc.5
        
        input tmode
        input tp
        input tm
        output rele
        'adcon1=7
        clear
    ss = tm         
    rele=0
    set=0
    i=0
    pause 100
    'lcdout $fe,1, "....."
    'Lcdout $fe, $C0," www....r"
    pause 2000
    'I2Cread SDA,SCL,$A0,0,[tz.lowbyte,tz.highbyte,toff,ton]
    if tz>600 then tz=200
    if toff=>100 then toff=5
    if ton=>100 or ton=0 then ton=5
    
    Pocetak:
    sn = tmode
     if sn<ss then  set= set + 1
        
      if set>3 then 
       set = 0
      endif 
           
    ss=sn
    select case set
        CASE 0
         znak1=" "
         znak2=" "     
         znak3=" "
         'call izmeri
         OWOut DQ, 1, [$CC, $44]   ' Start merenja temperature
         OWOut DQ, 1, [$CC, $44]      ' Start merenja temperature
     Cekaj:    OWIn DQ, 4, [cr]     ' Provera da li jos traje
            If cr = 0 Then Cekaj
            
            OWOut DQ, 1, [$CC, $BE]      ' Procitaj izmerenu temperaturu
            OWIn DQ, 0, [tt.LOWBYTE, tt.HIGHBYTE]', Skip 4, cr, cpc]
            
            If tt.bit15=1 then
             znak4="-"
             tt = abs(tt)
            else
             znak4="+"
            endif
            tt=(tt>>1)*10+tt.0*5   
         i=0  
        
        CASE 1 
         znak1=">"
         znak2=" " 
         znak3=" "
         if tp=0 and tz<600 then 
          tz=tz+5
          i=0
         endif 
         if tm=0 and tz=>5 then 
          tz=tz-5 
          i=0  
         endif
          'I2CWrite SDA,SCL,$A0,0,[tz.lowbyte,tz.highbyte]
        
        CASE 2
         znak1=" "
         znak2=">"
         znak3=" "
         if tp=0 and ton<100 then 
          ton=ton+5
          i=0
         endif 
         if tm=0 and ton=>5 then 
          ton=ton-5
          if Ton=0 and toff=0 then ton=5
          i=0  
         endif
         'I2CWrite SDA,SCL,$A0,3,[ton]
         
        CASE 3 
         znak1=" "
         znak2=" " 
         znak3=">"
         if tp=0 and toff<100 then 
          toff=toff+5
          i=0
         endif 
         if tm=0 and toff=>5 then
          toff=toff-5 
          if Ton=0 and toff=0 then toff=5
          i=0  
         endif
         'I2CWrite SDA,SCL,$A0,2,[toff]
         
    END SELECT 
    
     if tz+ton<=tt and set=0 and znak4="+" then 'ako je zadata temp manja od trenutne 
      rele=1                    'ukljuci rele
     endif                      
     if (tz=>toff and tz-toff=>tt and znak4="+") or (tz<toff and toff-tz<=tt and znak4="-" ) or set>0 then             'ako je zadata temperatura veca od trenutne ili si usao u meni
      rele=0
     endif
     
       
     i=i+1
     if i >100 then set = 4 'izadji iz menija
    
    'call prikazi
           'Lcdout $fe,1,znak1,"+",DEC2 (tz / 10), ".",#(tz dig 0),223, "C"
           'if set=0 then lcdout $fe,$89,znak4,DEC2 (tt / 10), ".",#(tt dig 0) ,223, "C" '178
           'Lcdout $fe, $C0, znak2,"+",DEC2 (ton / 10), ".",#(ton dig 0),223, "C",znak3,"-",DEC2 (toff / 10), ".",#(toff dig 0),223, "C"        
        
    pause 150
    goto pocetak
    If uncomment I2C or LCDOU, I get an error...
    Sorry for bad English...
    Last edited by pedja089; - 6th October 2010 at 20:51. Reason: Spelling

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


    Did you find this post helpful? Yes | No

    Default

    The 16F57 is a 12-bit core, which only has 2 stack levels.
    This puts restraints on what PBP can do.

    Therefore you cannot use modifiers like DEC HEX STR etc. in your LCDOUT statements.
    And I2C commands can only use fixed pins that are declared with DEFINE's.

    DEFINE I2C_SCL PORTA,1
    DEFINE I2C_SDA PORTA,0

    You can do it by tomorrow ... maybe
    DT

  5. #5
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel.
    I read a datasheet, and again I have not paid attention to the MCU ...
    I made a new PCB, the 16LF76, and works great ... now that I know what the problem is, I try to write a program that runs on 16F57. Now it should not be a problem.
    Thanks again.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Maybe...
    You can use SHIFTIN/OUT in place of I2C
    http://www.picbasic.co.uk/forum/cont...-EEPROM-Part-1
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    You can use the I2C statements with 12-bit cores.
    You just need to DEFINE the SCL and SDA pins.

    They still need to be specified in the I2C statements, but can't be changed at run-time.
    DT

  8. #8
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default

    mackrackit,very nice explanation. I did not know exactly how I2C works, now I know. It is easier to use and I2CREAD I2CWRITE, but this is also useful.

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