Trying to figure out what the compiler does not like about some code

Started by TimB, Jul 02, 2024, 04:42 PM

Previous topic - Next topic

TimB

Hi all

I'm working on some flash write subs but Positron is giving me a general syntax error for lines that look fine. I even commented them out and it complained


eg
        PMCON1bits_WREN = 1
        PMCON1bits_FREE = 1 

Any ideas


    Device 12f1572
    Declare xtal = 32


    Dim rPMADDRESS as Word at PMADRL
    DIm aFlashRamTemp[16] as byte


    Dim bIndex1 as byte

    dim cFlashRamDataStart as 0x7F0



Start:

    Osc_Int32MHz()


    EraseFlashRow(cFlashRamDataStart)


    For bIndex1 = 0 to 1

        aFlashRamTemp[bIndex1] = bIndex1

    Next



    WriteFlashRow(cFlashRamDataStart)



    While 1 = 1

        Nop


    Wend





    Proc EraseFlashRow(pAddress as word)

        PMCON1bits_WREN = 1
        PMCON1bits_FREE = 1          
        PMCON1bits_CFGS = 0                                                     '
        rPMADDRESS = pAddress
        PMCON2 = 0x55
        PMCON2 = 0xAA
        PMCON1bits_WR = 1
        NOP
        NOP

        PMCON1bits_WREN = 0
    EndProc                 





    Proc WriteFlashRow(pAddress as word)

        DIm bIndex as byte


        PMCON1bits_WREN = 1
        PMCON1bits_FREE = 0                                                     '
        PMCON1bits_CFGS = 0                                                     '

        bIndex = 0
        Repeat

            PMADR = pAddress
            PMDAT = aFlashRamTemp[bIndex]

            inc pAddress
            if bIndex <15 then
                PMCON1bits_LWLO = 1
            Else
                PMCON1bits_LWLO = 0
            Endif
        Until bIndex = 16


        PMCON2 = $55
        PMCON2 = $AA
        PMCON1Bits_WR = 1
        NOP
        NOp
       
        PMCON1bits_WREN = 0
    EndProc    `





'---------------------------------------------------------------------------------------------------
' Setup the device to use the internal oscillator at 32MHz
' Input     : None
' Output    : None
' Notes     : May not need to be called when using the 'RSTOSC_HFINTOSC_32MHZ' config1 fuse
'
Proc Osc_Int32MHz()
    OSCCON = %11110000                                                          ' 8 Mhz oscillator with PLL to give 32Mhz.
EndProc



'-------------------------------------------------------------------------------
'**** Added by Fuse Configurator ****
' Use the Fuses Tab to change these settings


Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_ON, CP_OFF, BOREN_ON, CLKOUTEN_OFF
Config2 WRT_OFF, PLLEN_ON, STVREN_ON, BORV_LO, LPBOREN_OFF, LVP_OFF

'**** End of Fuse Configurator Settings ****
'-------------------------------------------------------------------------------

trastikata

It compiles here when I copied your code.

Probably there's an ASCII code character outside of the supported by the IDE somewhere in your code, I found out this could be a problem sometime ago.

Copy your code back from the site here and paste it back in your code, should work since the site removes those characters.

TimB


Thanks trastikata

That solved it. I did try and copy it to a notepad and back again but got the same errors. It seems Notepad is not as a simple txt application as I thought.

Tim

John Lawton

I've had this issue from time to time. Invisible characters in source code that cause puzzling problems with compilers. It would be nice if the programming IDE's showed these characters on screen, in some form rather than making them invisible so they could then be removed.

John

RGV250

QuoteIt seems Notepad is not as a simple txt application
Not sure it would have helped but I always use Notepad++

Bob

DaveS

Quote from: TimB on Jul 02, 2024, 05:53 PMIt seems Notepad is not as a simple txt application as I thought.
To use Notepad to filter out non Ansi chars, paste the code into notepad and save changing the encoding to Ansi before saving.
The default setting saves a file as encoding UTF-8

normnet

Uncheck the following in FineLineIDE options:
Retain non ASCII Text else converts to spaces on file save and paste text.