• AVR Freaks

Hot!Unable to create PIC24F project

Author
peterg1000
Senior Member
  • Total Posts : 150
  • Reward points : 0
  • Joined: 2009/01/29 13:07:52
  • Location: Flamstead, Herts, UK
  • Status: offline
2020/01/19 04:44:21 (permalink)
0

Unable to create PIC24F project

Hi,
I badly need some expert help to get up and running with a PIC24F16KA102 project using assembler language.
 
I've been using MPLAB X 5.3 for a number of 8 bit projects and now wish to move to use 16 bit PIC24F devices.  I created a new project with the above processor declared and initially ran into a problem selecting an "ASM" toolchain. Searching on various forums I found that XC16 should be downloaded, as the assembler was now contained in that toolchain.

After downloading XC16 and apparently installing correctly, I recreated a new project and sure enough there are now two revisions of the compiler shown - v1.41 and v1.25.  However there is still a message calling for the latest version to be downloaded??

Went on to complete the project creation having selected v1.41, and attempted to assemble a trivial test programme (Setup.asm).  This failed with the following message :-

"make[2]: *** No rule to make target 'build/default/debug/_ext/1728301206/Setup.o', needed by 'dist/default/debug/Test_24bit.X.debug.elf'.  Stop."

Examining the beginning of the "makefile" shows :-
"
#
#  There exist several targets which are by default empty and which can be
#  used for execution of your targets. These targets are usually executed
#  before and after some main targets. They are:
#
#     .build-pre:              called before 'build' target
#     .build-post:             called after 'build' target
#     .clean-pre:              called before 'clean' target
#     .clean-post:             called after 'clean' target
#     .clobber-pre:            called before 'clobber' target
#     .clobber-post:           called after 'clobber' target
#     .all-pre:                called before 'all' target
#     .all-post:               called after 'all' target
#     .help-pre:               called before 'help' target
#     .help-post:              called after 'help' target
#
#  Targets beginning with '.' are not intended to be called on their own.
#
#  Main targets can be executed directly, and they are:
#  
#     build                    build a specific configuration
#     clean                    remove built files from a configuration
#     clobber                  remove all built files
#     all                      build all configurations
#     help                     print help mesage
"
etc, etc!!!  Not even a passing resemblance to the makefiles generated for the PIC18F projects

Clearly I have omitted something critical in the project creation process but have no idea where it went wrong.  I believe I followed the same process as when I created 8 bit PIC18F projects so would greatly appreciate some expert guidance.

Thanks




#1

17 Replies Related Threads

    LdB_ECM
    Super Member
    • Total Posts : 236
    • Reward points : 0
    • Joined: 2019/04/16 22:01:25
    • Location: 0
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/19 08:24:32 (permalink)
    +1 (1)
    Rename the file Setup.S ...  pretty sure XC16 doesn't know what ".asm" file is.
    #2
    peterg1000
    Senior Member
    • Total Posts : 150
    • Reward points : 0
    • Joined: 2009/01/29 13:07:52
    • Location: Flamstead, Herts, UK
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/19 10:23:59 (permalink)
    0
    Hi Ldb_ECM
    Thanks for that idea, quite right - did that but unfortunately it didn't affect the basic problem.
     
    I've reverted temporarily to MPLAB 8 to create a workable 16 bit project using ASM30. It's a slow-ish learning process taking care of the differences between 8 and 16 bit assembler file syntax.  At least I have a file that assembles OK now and am working on some linker error messages from the build process.
     
    regards
    Peter
    #3
    crennolet
    Super Member
    • Total Posts : 149
    • Reward points : 0
    • Joined: 2012/03/15 09:51:58
    • Location: 0
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/19 12:09:33 (permalink)
    +1 (1)
    OK. So I'm trying to duplicate your problem. I created a new standalone project, selected the PIC24F08KA102, simulator, no debug header, and XC16 (v1.41).
     
    Created an empty file, named it "asmtest.s" and put the following four lines in:
     
        .global _main
    _main:
        bra     _main
        .end
     
    (Why anyone would want to program the pic24 in assembly unless they want to create a different c startup routine is a mystery to me. I've written a *lot* of assembly over the years, and if I never have to write any more, well, that will be a nice thing...)
     
    and hit "clean and build".
     
    This is what happened (snipped off the top and some other stuff, left the compiler and linker lines -- and the result):
     
    <snip>
    "/opt/microchip/xc16/v1.41/bin/xc16-gcc" asmtest.s -o build/default/production/asmtest.o -c -mcpu=24F08KA102 -omf=elf -DXPRJ_default=default -legacy-libc -Wa,-MD,"build/default/production/asmtest.o.d",--defsym=__MPLAB_BUILD=1,-g,--no-relax -mdfp="/opt/microchip/mplabx/v5.30/packs/Microchip/PIC24F-KA-KL-KM_DFP/1.2.26"/xc16
    "/opt/microchip/xc16/v1.41/bin/xc16-gcc" -o dist/default/production/asmtest.X.production.elf build/default/production/asmtest.o -mcpu=24F08KA102 -omf=elf -DXPRJ_default=default -legacy-libc -Wl,,,--defsym=__MPLAB_BUILD=1,,--script=p24F08KA102.gld,--stack=16,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map="dist/default/production/asmtest.X.production.map",--report-mem,--memorysummary,dist/default/production/memoryfile.xml -mdfp="/opt/microchip/mplabx/v5.30/packs/Microchip/PIC24F-KA-KL-KM_DFP/1.2.26"/xc16
     
    <snip>
    BUILD SUCCESSFUL (total time: 756ms)
     
    #4
    peterg1000
    Senior Member
    • Total Posts : 150
    • Reward points : 0
    • Joined: 2009/01/29 13:07:52
    • Location: Flamstead, Herts, UK
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/20 05:04:30 (permalink)
    +1 (1)
    Hi crennolet,
    Thanks for taking the time to explore and document your solution to my difficulty.  I took your "Micky Mouse" programme and created a new project.  Results were exactly as you stated - built and ran first time!!! At least that proves my system software is properly installed and functional. 
     
    I can an only conclude that my original test file was rubbish, so I will try again with my test file that assembled and built OK under ASM30 and MPLAB 8.
     
    For you interest, I started my microprocessor work  in  the early 1970's with the Intel 8008!!  That needed a dozen or more 74N series IC's round it to get it to do anything useful. Wrote a boot loader of some dozen instructions to allow communication with a Teletype machine - those had to be entered by hand using switches. 
     
    Next came the 8080 - which was the basis for a suit of industrial control modules that I designed.  No such thing as high level languages for micros in those day - all assembler code.  Hence my preference that persists to this day - one knows EXACTLY what is going on!  Did learn the basics of C and I still have a copy of K & R somewhere, but never felt really comfortable with it.
     
    Anyway that's all history now.
     
    Many thanks for your guidance - much appreciated.
     
    Regards,
    Peter H
     
     
     
    #5
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Unable to create PIC24F project 2020/01/20 15:22:55 (permalink)
    +1 (1)
    You predate me a little Peter.
    I started (as a student) on 8080/Z80 in the 1970's, first with TRS80 Basic, then discovering how much faster machine language was.
    I then moved on to HD64180, all in assembler, in the 1980's.
    By the 1990's I'd experienced assembler on a variety of microcontrollers, finally settling on the PIC16F877 for a number of projects (using MPASM). I had a fair bit of exposure to all the incarnations of Visual Basic on the PC side, and dabbled in other people's C and C++ code, plus had to do a major project in using "Keil C" on a TI microcontroller.
    Once we decided to retire the PIC16F877A for any new projects, and started using the "enhanced midrange", I started using HiTech C instead of assembler, and have never looked back. HTC became XC8, and makes programming so much easier.
    It's certainly very helpful to have the assembler experience to see what the compiler is doing, and I'll occasionally use some inline assembler if I need absolute fastest code in some small loop, but 99% of my code is now all C.
    Using C also makes it MUCH easier to jump between various architectures without having to redo everything from scratch.
     
    So, my point is, have another crack at C. Once you get the basics sorted, it's so much more productive, and wen used properly, can catch a lot of programming errors for you.
     
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    dan1138
    Super Member
    • Total Posts : 3343
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/20 19:13:44 (permalink)
    +1 (1)
    @peterg1000

    Microchip has decided to make assembly programming for the PIC24/dsPIC33 difficult to setup the configuration words in a pure assembly project.

    It's best to use a C language source file to initialize the configuration words as the assembly language only method has been deprecated and for new controllers with partitioned flash it's not supported at all.

    I built a PIC24F16KA102 assembly language project for you and posted it on github here.

    I have only checked this with the simulator so real hardware may differ.
    #7
    peterg1000
    Senior Member
    • Total Posts : 150
    • Reward points : 0
    • Joined: 2009/01/29 13:07:52
    • Location: Flamstead, Herts, UK
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/21 04:16:32 (permalink)
    0
    @dan1138
    Really appreciate your effort on my behalf - you have saved me hours of head scratching (and probably cursing too!).
     
    Not quite sure how to move your files into a project on my PC yet - I assume the only ones I need to consider are in "24F16KA102_template_asm.X" .   Going to be an interesting learning exercise for sure.  One thing for certain is that you have saved me hours of trial and error - for that I am extremely grateful.
     
     @ric
    Good to hear from someone who has lived though the whole microprocessor era - there can't be many of us around!!  Spent most of my working life as a hardware / system designer - software was more a necessary means to an end in those days.   Only since retirement have I seriously "got into software"!!  Take your point about "C" though - perhaps now is the time to revisit and hopefully conquer
     
    Regards to both.
     
    Peter
    #8
    peterg1000
    Senior Member
    • Total Posts : 150
    • Reward points : 0
    • Joined: 2009/01/29 13:07:52
    • Location: Flamstead, Herts, UK
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/21 05:34:53 (permalink)
    +1 (1)
    @dan1138
     
    After a few false starts I now have your test project running.  Now the learning process begins in earnest.
     
    Thanks again for you valued help.
     
    Peter
    #9
    peterg1000
    Senior Member
    • Total Posts : 150
    • Reward points : 0
    • Joined: 2009/01/29 13:07:52
    • Location: Flamstead, Herts, UK
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/23 09:51:29 (permalink)
    0
    Light is beginning to dawn - but only slowly!!
     
    Noticed some annoying habits in MPLAB X 5.30 though :-
     
    1) Labels not displayed when examining programme memory.
    2) File register contents not updating when stepping through an assembler programme - have to change scope of window to get an update.
    3) Mousing over w0 through to w15, some locations fail to display the contents in a popup.
     
    Still running in "simulator mode", so these may not happen when running real hardware via PICkit 3.  When debugging 8 bit hardware line by line, the data seemed only to update after the next instruction was executed.
     
    I'm still not sure how to combine C code into an assembler file - I've not needed to do that at my present stage of learning, but can't locate any guidance in the manuals so far.
     
    #10
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Unable to create PIC24F project 2020/01/23 12:21:59 (permalink)
    0
    peterg1000
    I'm still not sure how to combine C code into an assembler file - I've not needed to do that at my present stage of learning, but can't locate any guidance in the manuals so far.
     

    If you're talking about anything other than the configuration bits, then you have to insert your assembler code into a C program. You can't have an isolated C function inside an assembler program.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #11
    peterg1000
    Senior Member
    • Total Posts : 150
    • Reward points : 0
    • Joined: 2009/01/29 13:07:52
    • Location: Flamstead, Herts, UK
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/23 12:59:03 (permalink)
    0
    Hi Ric,
    That's exactly what I wanted to know!!  Appreciate your help - many thanks.
     
    Sad to hear about the devastating wildfires affecting NSW - guess they are well away from you though.
    #12
    dan1138
    Super Member
    • Total Posts : 3343
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/23 15:15:25 (permalink)
    +1 (1)
    peterg1000
    I'm still not sure how to combine C code into an assembler file - I've not needed to do that at my present stage of learning, but can't locate any guidance in the manuals so far.

    Microchip has not produced any documentation on how to invoke a C function from within an assembly language program. It seems far from likely that they will ever support this implementation method.
     
    As ric has mentioned the "supported" way is to place assembly language in a C language source file using the ISOC/ANSI compliant compiler extensions supported by the GNU compiler. There is documentation provided by Microchip on these compiler extensions but few if any good examples of how best to use them well.
     
    MPLABX does a lame job of tracking symbols defined in an assembly language compilation unit (i.e. source file) so expect your experiences with the simulator to match what you will see with the PICKit3 or any other hardware In-Curcuit-Debug tool.
     
    Points of warning when using the ICD in real hardware:
    • Single stepping with more than a few items in the watch window will be slow.
    • Expect the debug session to crash when the watch window displays a lot of values.
      This does not occur when using the simulator.
    • In PIC24/dsPIC33 device, the values of objects in extended RAM spaces are not displayed correctly in the watch window or File Register window (i.e. data RAM). This is a known bug that showed up in MPLABX v3.xx that Microchip seems unable to fix in any comprehensive way.
    There are many other "quality-of-life" issues with MPLABX, I've just listed some that have annoyed me recently.
    #13
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Unable to create PIC24F project 2020/01/23 15:31:32 (permalink)
    +2 (2)
    peterg1000
    Sad to hear about the devastating wildfires affecting NSW - guess they are well away from you though

    Thanks. :)
    Eastern Victoria is affected also, but mainly holiday and farming areas. It has certainly been devastating for those that are affected.
    The only affect in Melbourne has been some very hazy weather, and "muddy rain" last Wednesday night...
    https://www.theage.com.au...s-20200123-p53tx0.html
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #14
    andersm
    Super Member
    • Total Posts : 2741
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/23 17:26:01 (permalink)
    0
    dan1138Microchip has not produced any documentation on how to invoke a C function from within an assembly language program. It seems far from likely that they will ever support this implementation method.

    Example 16-1 in the XC16 manual (v1.35) shows calling a C function from assembly. All you really need to know is the calling convention and the assembler's syntax for exporting and importing symbols.
    #15
    peterg1000
    Senior Member
    • Total Posts : 150
    • Reward points : 0
    • Joined: 2009/01/29 13:07:52
    • Location: Flamstead, Herts, UK
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/24 09:40:00 (permalink)
    +1 (1)
    Hi,
    Thanks everyone for the comments and advice in the various posts above.
     
    @ric      Thanks for the ".html " link - pretty unpleasant even well away from the fires.  Feel for the devastation of your beautiful country.
     
    @dan1138    I guess those problems emanate from trying to be all things to all men in one hugely complex package.  In spite of the occasional shortcomings, I do find it much easier and quicker to use for assembler debug than the old MPLAB v8, although the conversion to "X" was quite frustrating at first when every window seemed to disappear into the task bar at the slightest opportunity.  A real "Idiots Guide" is needed for people like me.
     
    @andersm    Appreciate your pointing out that example in the XC16 manual, it seems to resolve the problem of mixing C with assembler.  I presume that somewhere there is a concise list of the functions (and brief functionality) contained in the various C libraries (and of the libraries themselves of course).  Forgive my ignorance but I am a real beginner with "C" - but at least there is plenty of bedtime reading to be had!!
     
    Thanks for the PIC32 link - interesting reading there.
    #16
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Unable to create PIC24F project 2020/01/24 13:18:35 (permalink)
    0
    peterg1000
    ...
    I presume that somewhere there is a concise list of the functions (and brief functionality) contained in the various C libraries (and of the libraries themselves of course). 

    C:\Program Files (x86)\Microchip\xc16\v1.33\docs\16-Bit_Language_Tools_Libraries_Manual.pdf
    Update the version number to match your XC16 installation.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #17
    peterg1000
    Senior Member
    • Total Posts : 150
    • Reward points : 0
    • Joined: 2009/01/29 13:07:52
    • Location: Flamstead, Herts, UK
    • Status: offline
    Re: Unable to create PIC24F project 2020/01/24 14:46:36 (permalink)
    0
    Hi ric,
    Thanks for the link- there's such a plethora of documentation around that it's often difficult to know where best to start.  Pleased to say that I've also located my ancient copy of K & R (2nd ed) so now I'm all set for some intensive learning sessions.
     
    Regards
    #18
    Jump to:
    © 2020 APG vNext Commercial Version 4.5