• AVR Freaks

Hot!Has anyone used the toolchain "pic-as" in 2.20

Author
stenakew
Starting Member
  • Total Posts : 34
  • Reward points : 0
  • Joined: 2013/09/04 10:54:16
  • Location: 0
  • Status: offline
2020/05/28 15:43:43 (permalink)
0

Has anyone used the toolchain "pic-as" in 2.20

Hej.
A fresh Win 10 computer (no older Microchip tools installed)
Using MPLABX 5.40 and XC8 2.20
Curiosity (LPC) and a PIC16F1829
 
Starting a new project and selecting "pic-as (v2.20) [C:\Program Files\Microchip\xc8\v2.20\pic-as\bin]" as "Compiler Toolchain"
Without adding some files to the project, I select menu item "Window/Target Memory Views/Configuration Bits".
 
But it is not possible to change any configuration bits.
If I hit “Generate Source Code to Output” I get “Verify Compiler Toolchain highlighted: pic-as (v2.20) [C:\Program Files\Microchip\xc8\v2.20\pic-as\bin] : 2.20”
Ignoring the pic-as Compiler Toolchain and instead using XC.
Then, after some struggling, I managed to create a pure assembler program.
 
Selected
  • “Do not link startup module in”
  • “Link in C library” to “None”
In “XC8 Linker / Option categories / Runtime”
 
The project consisted of 3 files
 

;LED_1829_Basic_B.inc
 
    global  LED_Init
    global  LED4_On
    global  LED4_Off
   

 

;LED_1829_Basic_B.asm
   
#include    <xc.inc>
#include    "LED_1829_Basic_B.inc"
 
#define          LED4_TRIS   TRISA
#define          LED4_LAT    LATA
#define          LED4_BIT    5
   
PSECT LED, class="CODE", delta=2
                
LED_Init:
    banksel      LED4_LAT
    bcf          LED4_LAT, LED4_BIT
    banksel      LED4_TRIS
    bcf          LED4_TRIS, LED4_BIT
    return
   
LED4_On:
    banksel      LED4_LAT
    bsf          LED4_LAT, LED4_BIT
    return
   
LED4_Off:
    banksel      LED4_LAT
    bcf          LED4_LAT, LED4_BIT
    return

 

;main_1829_Basic_B.asm
 
#include <xc.inc>
#include "LED_1829_Basic_B.inc"
   
;configuration
CONFIG FOSC=INTOSC
CONFIG WDTE=OFF,PWRTE=OFF
CONFIG MCLRE=ON
CONFIG CP=OFF,CPD=OFF
CONFIG BOREN=ON
CONFIG CLKOUTEN=OFF
CONFIG IESO=OFF
CONFIG FCMEN=OFF
CONFIG WRT=OFF
CONFIG PLLEN=OFF
CONFIG STVREN=ON
CONFIG BORV=LO
CONFIG LVP=ON
 
PSECT reset_Vec,class=CODE,delta=2
resetVec:
    PAGESEL start
    goto start
 
PSECT udata
delay_ms:            ds 1
delay_ms_counter:    ds 1
 
PSECT int_Vec,class=CODE,delta=2
intVec:
    retfie
 
PSECT code
start:
    call    LED_Init
   
main_loop:
    call    LED4_On
    movlw   200
    call    Delay_ms
    call    LED4_Off
    movlw   200
    call    Delay_ms
    goto    main_loop
 
;----------------------------
;delay a number of ms
;
;entry W = number of ms
;exit  -
   
#define     DELAY_MS_COUNT  40
 
Delay_ms:
    banksel delay_ms
    movwf   delay_ms
Delay_ms_1:
    movlw   DELAY_MS_COUNT
    movwf   delay_ms_counter
Delay_ms_2:
    decfsz  delay_ms_counter, F
    goto    Delay_ms_2
    decfsz  delay_ms, F
    goto    Delay_ms_1
    return
 
;Some PSECT's requested by the linker, but newer used
PSECT powerup,class=CODE,delta=2
PSECT cinit,class=CODE,delta=2
PSECT functab,class=CODE,delta=2
PSECT eeprom_data, class="EEDATA",delta=2
 
END resetVec

 
I also had to add 2 PSECT definitions to the linkers “Additional options”. (Also added the option to generate a map file.)
 
-Wl,-Map=mapfile.map -Wl,-preset_Vec=0h -Wl,-pint_Vec=4h
 
Is there any other way using MPLABX 5.40 and XC8 2.20 to create a pure assembler program?
 
 
 
#1

15 Replies Related Threads

    sdn_
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2020/03/08 02:14:28
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/05/30 00:42:43 (permalink)
    +1 (1)
    I also created a test project for PIC18 on PIC-AS. For me it consists of only one file. For debugging, I needed the contents of the listing.disasm file, however it does not contain a disassembler. Show what you have in this file? If nothing, then the microchip seriously complicates the development of programs for 8 bit microcontrollers in assembly language.
    #2
    dan1138
    Super Member
    • Total Posts : 3858
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/05/30 14:30:22 (permalink)
    +3 (3)
    I ported your LED blinky app into a pic-as assembly project template I created.

    It builds using the pic-as(v2.20) "Compiler Toolchain", other than not being able to change the configuration words using the IDE interface it seem to run.

    To get debug working is a whole different bucket of bait.

    I have not been able to get the IDE to do source level debug when using the pic-as(v2.20) "Compiler Toolchain".

    Using a hack to start such a debug session by "importing" the ELF output from a debug build into a "prebuilt" MPLABX project runs, but the simulator stopwatch does not work.

    <rant>
    How the simulator works (or fails to work) with the MPLABX IDE is nuttier than squirrel poo.

    I know programming with assembly language tends to get weird but, Microchip seems to have mixed in a lot of chopped stupid with this release.
    </rant>
    #3
    sdn_
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2020/03/08 02:14:28
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/05/30 14:51:16 (permalink)
    0
    ASM16 (XC16) has an output listing.disasm and a normal simulator (as it was in MPASM). Therefore, i think that the microchip will later add these functions to pic-as .
    #4
    dan1138
    Super Member
    • Total Posts : 3858
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/05/30 15:20:29 (permalink)
    +1 (1)
    sdn_
    ASM16 (XC16) has an output listing.disasm and a normal simulator (as it was in MPASM). Therefore, i think that the microchip will later add these functions to pic-as .

    It seems my point was not made clearly enough.
     
    The XC8 compiler for C language works now with source level debug. The final output from the C compiler comes for the pic-as tool.
     
    But then source level debug is not available when using the pic-as(v2.20) "Compiler Toolchain". This suggests that the IDE is ignoring the source level debug provided by the pic-as assembler. Perhaps in favor of the C language debug symbols. These will not be present as the C compiler is not used for this tool chain.
     
    It appears that the pic-as assembler produces source level debug symbols because MPLABX IDE will use them when a prebuilt ELF file is imported from a pic-as assembly project.
    post edited by dan1138 - 2020/06/01 13:25:58
    #5
    kmhillatuha
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2020/06/25 17:34:33
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/09 20:11:26 (permalink)
    0
    Hello folks;
    I've been struggling with pic-as as well. As a first step, rather than full disassembly, I've looked at the program memory, the viewer provides disassembly. From MPLAB X IDE:
    Window >> Target Memory Views >> Program Memory
    I tried the example in section 3 of the MPLAB XC8 Assembler User's Guide for Embedded Engineers and found that the given code didn't produce in program memory a goto instruction to direct to the actual program. Please take a look to see if this is the case for you as well. After some digging I learned that PSECT switch abs works with the ORG directive so the following produced the necessary goto instruction, though I'm not sure about it.

    PSECT resetVec, class="CODE", abs
        ORG  0x00000
    resetVec:
        goto main

    Regarding debugging, I placed a breakpoint and then the simulator/debugger gives me the error:
    Break point at line 74 in file J:/Courses/Tools/Microchip/Asm03/Asm03.X/main.asm cannot be resolved to a valid program memory address
    So I agree, something may be awry with the symbols.
     
    post edited by kmhillatuha - 2020/07/09 20:14:19
    #6
    kmhillatuha
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2020/06/25 17:34:33
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/09 21:04:04 (permalink)
    0
    Section 3 of the MPLAB XC8 Assembler User's Guide for Embedded Engineers confirms that without explicit placement instructions, the goto main instruction would end up somewhere else. I'll read all of section 3 more closely...
     
    #7
    XGenerator
    Administrator
    • Total Posts : 351
    • Reward points : 0
    • Joined: 2009/10/12 12:11:03
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/10 11:08:52 (permalink)
    +2 (2)
    To answer the top post the config bit generator for PIC-Assembler has not been implemented as yet in the IDE. Please add the config bit macros directly to your source.
    As for debugging we are looking into this.
    thanks
    #8
    cea
    Super Member
    • Total Posts : 121
    • Reward points : 0
    • Joined: 2006/02/17 00:01:25
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/10 16:38:27 (permalink)
    +1 (1)
    I started a support request on 24-June-2020 this is the resolution:
    MicrochipSupport
    Content anonymized a bit:
     
    Created : (7/7/2020, 18:09)
     
    Our software team shared a workaround:
     
    "A temporary work around for customers of 5.40 is to open nbproject/Makefile-default.mk (from their project) and manually change the line DEBUGGABLE_SUFFIX=hex to DEBUGGABLE_SUFFIX=elf. This will work, but it has to be re-done each time the customer opens the project properties and changes any other project setting."

    #9
    dan1138
    Super Member
    • Total Posts : 3858
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/10 17:09:54 (permalink)
    +3 (3)
    charles@socketcom
    I started a support request on 24-June-2020 this is the resolution:
    MicrochipSupport
    Content anonymized a bit:
     
    Created : (7/7/2020, 18:09)
     
    Our software team shared a workaround:
     
    "A temporary work around for customers of 5.40 is to open nbproject/Makefile-default.mk (from their project) and manually change the line DEBUGGABLE_SUFFIX=hex to DEBUGGABLE_SUFFIX=elf. This will work, but it has to be re-done each time the customer opens the project properties and changes any other project setting."



    OK, Mr. Clever Clogs:
     
    I just tried this and it does not work.
     
    So it would seem that the software team does not know how to correct this fault.
     
    Attached is the project I am using.
     
    Please tell me what to change to make this work.
    #10
    cea
    Super Member
    • Total Posts : 121
    • Reward points : 0
    • Joined: 2006/02/17 00:01:25
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/10 17:19:00 (permalink)
    +2 (2)
    Hey, you're right.
     
    The software team gave the support staff a non-work around and I believed them.
     
    I am stupid.
     
    In any case the method you described of importing the ELF file as a prebuilt project seems to work for me.
     
    Thanks.
    #11
    kmhillatuha
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2020/06/25 17:34:33
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/10 17:20:25 (permalink)
    0
    Thanks cea, just gave it a try. I made the edit you described and used the following to build
    Production >> Clean and Build Main Project
    The debugger reports the same error, I don't see any change. Bummer!
    Break point at line 74 in file J:/Courses/Tools/Microchip/Asm04/Asm04.X/main.asm cannot be resolved to a valid program memory address
    Launching
    Initializing simulator
    User program running
     

    Please let me know if you see a change. Also, I'm curious if the extension for your source file is .asm or .S. It appears that a file with a .S extension uses a more complicated build process.
    post edited by kmhillatuha - 2020/07/10 17:38:06
    #12
    cea
    Super Member
    • Total Posts : 121
    • Reward points : 0
    • Joined: 2006/02/17 00:01:25
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/10 17:39:31 (permalink)
    0
    It seems that dan1138 is right, the work around does not seem to load any of the debug symbols.
     
    Try using the method of importing the "build for debug" ELF file as a prebuilt project.
    #13
    kmhillatuha
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2020/06/25 17:34:33
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/10 19:04:26 (permalink)
    0
    Hi folks;
     
    First off, dan1138, I'd like to know in the basic example you posted, how you placed the reset goto, to address 0x00000. I can see in the call to link that the needed switch -presetVec=0h is being used, but I'm not sure how you've configured the IDE to do that. Please, I'd like to know.
     
    Regarding the method of importing the "build for debug" ELF file as a prebuilt project, I'm feeling my way through this. So far I gather that to build I'd use:
    Debug >> Discrete Debugger Operation >> Build for Debugging Main Project
     
    Next, I found the following, but I'm not sure what the next step would be:
    File >> Import Hex/Elf ... (Prebuilt) File
     
    I found the ELF file in the dist\default\debug sub-folder. Despite clicking the "Make main project" choice, I found that I had to manually assign the new prebuilt project as main. I'll be practicing this...
    post edited by kmhillatuha - 2020/07/10 19:13:05
    #14
    dan1138
    Super Member
    • Total Posts : 3858
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/10 19:49:25 (permalink)
    +2 (2)
    kmhillatuha
    First off, dan1138, I'd like to know in the basic example you posted, how you placed the reset goto, to address 0x00000. I can see in the call to link that the needed switch -presetVec=0h is being used, but I'm not sure how you've configured the IDE to do that.

    Please, I'd like to know.

    The documentation is in the first few lines in the test.S source file:
    ; 
    ; Code example from section 3.  A Basic Example For PIC18 Devices
    ;
    ; From document: http://ww1.microchip.com/downloads/en/DeviceDoc/XC8-PIC-Assembler-UG-for-EE-50002994A.pdf
    ;
    ; Add this line in the project properties box, pic-as Global Options -> Additional options:
    ;   -Wl,-Map=test.map -Wl,-presetVec=0h
    ;

    If this line does not make sense to you:
    ; Add this line in the project properties box, pic-as Global Options -> Additional options:

    You have no chance of building your own assembly language project.

    This specific line:

    ;   -Wl,-Map=test.map -Wl,-presetVec=0h

    Tells the IDE to produce a file that shows where the linker located all the sections.

    It also tells the linker to locate the section named: "resetVec" at address 0x0000.


    One additional thing is that exactly one END directive is required in an assembly language project.

    The END directive should have a parameter that is a symbol that identifies the power-on-reset entry point of the project.

    You should notice that the symbol "resetVec:" is declared in the "resetVec" section and the "resetVec" symbol is the parameter of the END directive.

    The section name and this symbol are not required to be the same. This is just how Microchip created this code.
    #15
    kmhillatuha
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2020/06/25 17:34:33
    • Location: 0
    • Status: offline
    Re: Has anyone used the toolchain "pic-as" in 2.20 2020/07/11 14:04:51 (permalink)
    0
    Thanks much, I found the pic-as Global Options that you entered. I learned my lesson to slow down. Yes indeed, documentation and good comments help. Thanks for putting them here. It all makes sense. :-)
     
    post edited by kmhillatuha - 2020/07/11 17:10:05
    #16
    Jump to:
    © 2020 APG vNext Commercial Version 4.5