News:

Let's find out together what makes a PIC Tick!

Main Menu

I have interesting compiler error

Started by Maxi, Apr 12, 2022, 09:49 AM

Previous topic - Next topic

Maxi

when I compile this code with old "Version 3.7.5.5" done.
but, "Version 4.0.1.5" give me an error and hex not created.
"symbol not previously defined (BUZZ1)"

What is my mistake?

Device = 16F1847
Declare Xtal=8
OSCCON=%01110010
Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_OFF, CP_ON, CPD_ON, BOREN_OFF, CLKOUTEN_OFF, IESO_OFF, FCMEN_OFF
Config2 WRT_OFF, PLLEN_OFF, STVREN_OFF, LVP_OFF

TRISA=%00000000
TRISB=%00011011

ADCON0=%00001011
ADCON1=%10110000
ANSELB=%00011000

OPTION_REG.7=0

Symbol BUZZER=PORTA.6       
Dim ARRAY10[10] As Byte

Dim Gelen As String * 9
Gelen="         "

Dim BAZIR As String * 9
BAZIR="SSSSSSS  "

Dim Resetle As String * 9
Resetle="RRRRRRR  "


MAIN:
Gelen[0]=ARRAY10[1]
Gelen[1]=ARRAY10[2]
Gelen[2]=ARRAY10[3]
Gelen[3]=ARRAY10[4]
Gelen[4]=ARRAY10[5]
Gelen[5]=ARRAY10[6]
Gelen[6]=ARRAY10[7]

'---------------------------------
If Gelen=Resetle Then
High PORTA.0
GoSub BUZZ1

EndIf
'---------------------------------
If Gelen=BAZIR Then
High PORTA.1
GoSub BUZZ1
   
EndIf
'---------------------------------
GoTo MAIN

BUZZ1:
High BUZZER
DelayMS 50
Low BUZZER
Return


pjdenyer

The following code now compiles, however, the code does not do anything apart from looping around MAIN as you never change Gelen.


Device = 16F1847
Declare Xtal=8
OSCCON=%01110010
Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_OFF, CP_ON, CPD_ON, BOREN_OFF, CLKOUTEN_OFF, IESO_OFF, FCMEN_OFF
Config2 WRT_OFF, PLLEN_OFF, STVREN_OFF, LVP_OFF

TRISA=%00000000
TRISB=%00011011

ADCON0=%00001011
ADCON1=%10110000
ANSELB=%00011000

OPTION_REG.7=0

Symbol BUZZER=PORTA.6       

Dim Gelen As String * 9
Gelen="         "

Dim BAZIR As String * 9
BAZIR="SSSSSSS  "

Dim Resetle As String * 9
Resetle="RRRRRRR  "


MAIN:
   
    '---------------------------------
    If Gelen=Resetle Then GoSub BUZZ1
    '---------------------------------
    If Gelen=BAZIR Then GoSub BUZZ1
    '---------------------------------

GoTo MAIN

BUZZ1:

    High BUZZER
    DelayMS 50
    Low BUZZER
    Return

Pepe

#2
and where gelen is assigned to run the gosub?

Maxi

#3
thank you but Im cut unnecessary lines.
now add some lines, error again

*and, this code compile verywell with 18F25K22
Im just add this and remove old device and config lines (also remove option_reg line)
and compile
Device 18F25K22
Declare Xtal=8

top204

The BUZZ1 subroutine will never be called, because the String named Gelen is holding the text "         ", while both the Strings BAZIR and Resetle are holding the texts "SSSSSSS  " and "RRRRRRR  ", so they will never be equal to each other!

Change the contents of the Gelen String to match one of the others, and the subroutine will be called.

tumbleweed

Ignoring any logic errors for the moment, here's a simplified version of Maxi's original post
that compiles ok for an 18F26K22, but fails when compiled for a 16F1847.

I think that's his point...

'Device = 16F1847       ' symbol not previously defined (BUZZ1)
Device=18F26K22         ' builds ok
Declare Xtal=8

Symbol BUZZER=PORTA.6      
Dim ARRAY10[10] As Byte

Dim Gelen As String * 9
Gelen="         "

Dim BAZIR As String * 9
BAZIR="SSSSSSS  "

Dim Resetle As String * 9
Resetle="RRRRRRR  "


MAIN:
Gelen[0]=ARRAY10[1]
Gelen[1]=ARRAY10[2]
Gelen[2]=ARRAY10[3]
Gelen[3]=ARRAY10[4]
Gelen[4]=ARRAY10[5]
Gelen[5]=ARRAY10[6]
Gelen[6]=ARRAY10[7]

'---------------------------------
If Gelen=Resetle Then
    High PORTA.0
    GoSub BUZZ1
EndIf
'---------------------------------
If Gelen=BAZIR Then
    High PORTA.1
    GoSub BUZZ1
EndIf
'---------------------------------
GoTo MAIN

BUZZ1:
High BUZZER
DelayMS 50
Low BUZZER
Return

John Lawton

When compiling for the 16F1847 I get:

"Error[113] .....A.S. 579 : Symbol not previously defined (BUZZ1)"
"ASSEMBLER ERRORS. HEX file not Created"


Maxi

yes, thank you john and tumbleweed
I can compile same code with 18F26K22 but not 16F1847 or 16F1827
what is missing?

top204

Many thanks for the clarity tumbleweed.

Yes... There was a strange anomaly going on with comparisons of Strings, but only if there is an Endif, and only String comparisons in the program. And "only" on enhanced 14-bit core devices!

It has now been corrected, and was down to the compiler's mechanism for trying to tie the, dreadfully, fragmented RAM of the 14-bit core devices together, which caused an internal exception in some cases, and stopped the rest of the assembler code being created. :-)

I will be uploading a free update ASAP.




Maxi

Now compile well after installing 4.0.1.7 patch.
Thank you