• AVR Freaks

Hot!Defines and Macros locations

  • Total Posts : 24
  • Reward points : 0
  • Joined: 2019/12/28 20:45:42
  • Location: East Coast
  • Status: offline
2020/02/02 12:43:14 (permalink)
5 (1)

Defines and Macros locations

I am very impressed with Harmony 3.  One issue I have is that I can't find various header files, at least I think that would be where I could find the #defines and #pragmas I am looking for.  In "hiding" the details, the details get hidden from someone who wants to "drill down".   MPLAB X IDE does not seem to have an easy way to display values not in project files, and looking around, I cannot easily find them myself.  What it looks like, is the files might be built as part of the compile/built step.  Or maybe it happens during the "generate code" step.  (just guessing)
For example, I am presently working on the UART2 interrupt routines.  I want to adjust them to use FreeRtos streams.  Not a difficult thing to do, and actually I do not *really* need to find to files I am looking for, I can guess (likely correctly) what these constants are.
_U2STA_OERR_MASK   likely equals  0x0002    but it would be nice to see where it is defined to be sure.
U2STACLR    is likely a $pragma  that clears a bit in the U2STA  register.
Is there an easy way to find and look at these headers files?

3 Replies Related Threads

    Klaatu Barada Nikto
    • Total Posts : 3840
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Defines and Macros locations 2020/02/02 13:15:38 (permalink)
    Header files are here:
    Program Files(86)/Microchip/xc16/*version*/support
    Program Files(86)/Microchip/xc16/*version*/docs/config_index
    Relevant docs:
    Program Files(86)/Microchip/MPLABX/*version*/docs
    post edited by Gort2015 - 2020/02/02 13:33:48

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    + ST:Continues, "What Ships are Made for", Q's back.
    Super Member
    • Total Posts : 3670
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Defines and Macros locations 2020/02/02 15:18:20 (permalink)
    Those macros mentioned in message #1:  U2STACLR    and  _U2STA_OERR_MASK,
    are not defined by Harmony, but by XC32 compiler.
    Or more precisely by device support files that are distributed and installed together with the compiler.
    Those symbol definitions are made available by:
        #include <xc.h>      
    Individual device support file for each PIC32 device type are stored somewhere like:
    "C:\Program Files (x86)\Microchip\xc32\v2.30\pic32mx\include\proc\*.h"
        U2STACLR  is a variable name for a register in SFR space.
    Together with
        U2STA      register, there are also:
        U2STASET  and
        U2STAINV   registers,  that control hardware gates in Peripheral registers,
    that combine existing register value in U2STA, with the mask value written to _CLR, _SET or _INV register.
    Read about ...CLR, ...SET and ...INV    in Datasheet and FRM  document  for the  PIC32 device you are using.
    Super Member
    • Total Posts : 26973
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Defines and Macros locations 2020/02/02 15:27:22 (permalink)
    Read about ...CLR, ...SET and ...INV    in Datasheet and FRM  document  for the  PIC32 device you are using.

    and understand the reason these registers exist is that the PIC32 architecture is very inefficient at modifying register bits via bitfields.
    Any sort of read-modify-write involves multiple bus cycles to implement.
    The CLR/SET/INV alternatives enable you to manipulate bits with just a write.

    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!
    Jump to:
    © 2020 APG vNext Commercial Version 4.5