News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Error Code 115

Started by charliem, Sep 06, 2024, 07:54 PM

Previous topic - Next topic

charliem

Hello everyone it's been a long time sense I posted here. I am messing about with Positron using a CCP example and Im having some trouble. 
Attached is the lST file. any help is appreciated. Thanks.


Charlie

charliem

Ok removed and reinstalled the compiler and the latest upgrade and the latest corrections update
I still get the error.
I selected a different pic and still get the error.

RGV250

Hi Charlie,
How about posting the .bas file so we can have a look.

Bob

charliem

No problem. Its just the CCP example on the samples folder. here it is


'
'   /\\\\\\\\\
'  /\\\///////\\\
'  \/\\\     \/\\\                                                 /\\\          /\\\
'   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
'    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
'     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
'      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
'       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
'        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
'                                  Let's find out together what makes a PIC Tick!
'
' Program to demonstrate the use of the hardware capture
' module to measure the period of a frequency input.
'
' Also shows how two hardware registers can be combined for a 16-bit result
' Input signal should be connected to RC2/CCP1
'
' Written by Les Johnson for the Positron8 BASIC compiler.
' https://sites.google.com/view/rosetta-tech/home
'
    Include "Proton_20.Inc"                ' Configure ports for Positron8 board

    Declare Float_Display_Type = Fast

    Dim Period As Word                      ' Word variable that stores the captured value
    Dim Frequency As Float

    Symbol CCPR1 = CCPR1L.Word              ' Create a 16-bit variable out of CCPRL1
    Symbol Timer1 = TMR1L.Word              ' Create a 16-bit variable out of TMR1L
    Symbol Capture = PIR1.2                 ' CCP1 capture flag
    Symbol Overflow    = PIR1.0             ' Timer1 overflow flag

'------------------------------------------------------------------------
' The main program starts here
'
    DelayMS 100                             ' Wait for things to stabilise
    Cls
    CCP1CON = %00000100                     ' Enable the CCP1 capture, falling edge
    T1CON = %00000001                       ' TMR1 prescale=1, and turn it on (1uS per count)

    Do
        While Capture = 0 : Wend            ' Wait here until captured
        Period = CCPR1                      ' Store the captured value in period variable
        If Overflow = 0 Then                ' Skip the output if the timer overflowed
            Print At 1,1, "Period: " , Dec Period , "uS  "    ' Output
            Print At 2,1, "Freq: " , Dec2 5000.0 / Period,"KHz  "
        EndIf
        Capture = 0                         ' Clear the capture flag

        While Capture = 0 : Wend            ' Wait for beginning of next period
        Clear Timer1                        ' Clear Timer1
        Capture = 0                         ' Clear capture flag
        Overflow = 0                        ' Clear overflow flag
    Loop                                    ' Do it forever

RGV250

Hi,
It must be an issue with the def or ppi file?

rename these 2 lines
    Symbol CCPR1_anything= CCPR1L.Word
    Period = CCPR1_anything   

and it will compile.

Bob     

charliem


top204

#6
The device already has an SFR named "CCPR1H", so the assembler gives the error that there are two of them declared.

In the program listing, when CCPR1 is made into a 16-bit SFR, the compiler will name them CCPR1 and CCPR1H, but the device already has an SFR named that at address 0x0FBF. See the device's .PPI file for the SFRs on the device.

Whenever creating a 16-bit SFR, give it a name that is different to the SFR name, but also recognised for what it is, and either add a preceding lowercase "w", or give it a name that shows what it is. For example:

Dim wCCPR1 As CCPR1L.Word

Or better:

Dim wCCPR1_SFR As CCPR1L.Word

The same with the Timer1, 16-bit combination you have in the code listing, it would be better named as:

Dim wTimer1 As TMR1L.Word

Or better:

Dim wTimer1_SFR As TMR1L.Word

Then they are both clearly viewed as 16-bit SFRs in the code listing, because of the preceding lowercase "w", and easier to follow.

In my experience as a programmer for so many years, I have found it better to have names that are easier to view, and see what they are. And especially with microcontrollers, their size, with a preceding character of 't', 'b', 'w', 'l', 'd', 'f', or 'c'. where:

't' is for a Bit variable (also known as a tetra). So: Dim tIsItValid As Bit
'b' is for a Byte variable. So: Dim bThisTestVar As Byte
'w' is for a Word variable. So: Dim wThatTestVar As Word
'l' is for a Long variable. So: Dim lAnotherTestVar As Long
'd' is for a Dword variable. So: Dim dLoopCounter As Dword
'f' is for a Float variable. So: Dim fResultOfCalc As Float
'c' is for a Constant. So: Symbol cSizeMinusOne = (125476 - 1)

etc...

Then when looking through the code listing, you can see what type the variable is, as well as a meaningful name, and make sure comparisons and expressions etc, are suitable for the size.

I must find the time to go through the compiler sample programs and adjust them to be more readable. However, there are lots of them, so it will take a while.