News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

ASM ERROR using COUNTER command with 33FJ12GP202

Started by Wimax, May 02, 2022, 11:10 AM

Previous topic - Next topic

Wimax

Hello,

I'm trying to use the "Counter" command of Positron16, but I get :"ASM ERROR: Linker Error (...) undefined reference to '_counter-". ASM ERROR hex file not created.
This is a simple code just to try the command...

Device=33FJ12GP202
Declare Xtal= 39.6288
PLL_Setup(43, 2, 4, $0300)   '  39.6288 MHz
Config FBS = BWRP_WRPROTECT_OFF
Config FGS = GWRP_OFF
Config FOSCSEL = FNOSC_PRIPLL, IESO_ON
Config FOSC = POSCMD_XT, IOL1WAY_OFF, FCKSM_CSECME
Config FWDT = WDTPOST_PS256, WINDIS_OFF, FWDTEN_OFF
Config FPOR = FPWRT_PWR128, ALTI2C_OFF
Config FICD = ICS_PGD1, JTAGEN_OFF
Symbol CounterPin = PORTB.11
Dim Conta As Word
Main:
Conta=Counter CounterPin, 100
DelayMS 100      ' Do nothing...
GoTo Main



top204

Whoops.... I forgot to add the flag to include the compiler's built-in Counter library subroutine. Crickey.... This has been like that from the day I created the 16-bit compiler. So much for public Beta testing. :-)

It has now been corrected, however, there is a better method using a library include file I created many years ago, and contained in the compiler's "Includes" folder: "C:\Users\User Name\PDS\Includes\". Files in this directory can be seen by all programs and is the place to add library files that are created for all programs to see and use.

The file in question is the "Counter.inc" file, and it performs the same task as the compiler's built-in library subroutine for Counter, but is written with a mixture of high level and low level commands, so it can be examined and altered if required.

Below is a demo program I created when I was first writing the 16-bit compiler and creating the built-in commands, so I could create them in high-level, then use the assembler code produced for the compiler. It does not use any peripherals, so it can be used on any PIC24 or dsPIC33 device.

'
'   /\\\\\\\\\
'  /\\\///////\\\
'  \/\\\     \/\\\                                                 /\\\          /\\\
'   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
'    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
'     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
'      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
'       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
'        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
'                                  Let's find out together what makes a PIC Tick!
'
' Demonstrate the replacement routine for the compiler's Counter command
'
' The "Counter.inc" library file can be found in the compiler's "Includes" folder:
' "C:\Users\User Name\PDS\Includes\"
'
' Written by Les Johnson for the Positron16 compiler
'
    Device = 24FJ64GA002
    Declare Xtal = 32

    Declare Hserial_Baud = 9600                     ' UART1 baud rate
    Declare Hrsout1_Pin = PORTB.14                  ' Select which pin is to be used for TX with USART1

    Include "Counter.inc"                           ' Load the counter command replacement into the program

    Dim MyWord As Word

'---------------------------------------------------------------------------
' The main program starts here
'
Main:
    PPS_Output(cOut_Pin_RP14, cOut_Fn_U1TX)         ' Make PPS Pin RP14 U1TX

    Do
        MyWord = Counter PORTA.0,1000
        HRSOut Dec MyWord, 13       
    Loop

Wimax

Hi Les ! Honored to be a beta tester for positron16 ! ;D  I tried to insert the "Counter.inc" file and it works perfectly in the short listing I posted.
In another program, a bit more complex, I had to insert Include "Counter.inc" just before the point where I needed it and it worked without problems.
Loading it at the beginning of the program generated a series of errors on the many procedures present after.