Gratuitous changes to CMSIS types and defines in MPLABX ??!!

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So I downloaded the latest MPLABX, which apparently comes with "packs" from https://packs.download.microchip.com/ , which are a couple of versions past the "Atmel Packs" at http://packs.download.atmel.com/

I suppose that that would be OK, except that it looks like pretty much ALL of types and top-level peripheral definitions have changed !!!

 

Atmel (..../Atmel.SAMC21_DFP.1.2.176/samc21/include/samc21g18a.h)

#define PORT              ((Port     *)0x41000000UL) /**< \brief (PORT) APB Base Address */
#define PORT_IOBUS        ((Port     *)0x60000000UL) /**< \brief (PORT) IOBUS Base Address */
#define PORT_INST_NUM     1                          /**< \brief (PORT) Number of instances */
#define PORT_INSTS        { PORT }                   /**< \brief (PORT) Instances List */
#define PORT_IOBUS_INST_NUM 1                          /**< \brief (PORT) Number of instances */
#define PORT_IOBUS_INSTS  { PORT_IOBUS }             /**< \brief (PORT) Instances List */

#define PTC               ((void     *)0x42005800UL) /**< \brief (PTC) APB Base Address */
#define PTC_GCLK_ID       37
#define PTC_INST_NUM      1                          /**< \brief (PTC) Number of instances */
#define PTC_INSTS         { PTC }                    /**< \brief (PTC) Instances List */

#define RSTC              ((Rstc     *)0x40000C00UL) /**< \brief (RSTC) APB Base Address */
#define RSTC_INST_NUM     1                          /**< \brief (RSTC) Number of instances */
#define RSTC_INSTS        { RSTC }                   /**< \brief (RSTC) Instances List */

#define RTC               ((Rtc      *)0x40002400UL) /**< \brief (RTC) APB Base Address */
#define RTC_INST_NUM      1                          /**< \brief (RTC) Number of instances */
#define RTC_INSTS         { RTC }                    /**< \brief (RTC) Instances List */

#define SDADC             ((Sdadc    *)0x42004C00UL) /**< \brief (SDADC) APB Base Address */
#define SDADC_INST_NUM    1                          /**< \brief (SDADC) Number of instances */
#define SDADC_INSTS       { SDADC }                  /**< \brief (SDADC) Instances List */

#define SERCOM0           ((Sercom   *)0x42000400UL) /**< \brief (SERCOM0) APB Base Address */
#define SERCOM1           ((Sercom   *)0x42000800UL) /**< \brief (SERCOM1) APB Base Address */

 

 

Microchip (...mplabx/v5.25/packs/Microchip/SAMC21_DFP/3.0.22/samc21/include/samc21g18a.h)

#define PORT_REGS                        ((port_registers_t*)0x41000000)               /**< \brief PORT Registers Address       */
#define PORT_IOBUS_REGS                  ((port_registers_t*)0x60000000)               /**< \brief PORT Registers Address       */
#define PTC_REGS                         ((ptc_registers_t*)0x42005800)                /**< \brief PTC Registers Address        */
#define RSTC_REGS                        ((rstc_registers_t*)0x40000c00)               /**< \brief RSTC Registers Address       */
#define RTC_REGS                         ((rtc_registers_t*)0x40002400)                /**< \brief RTC Registers Address        */
#define SDADC_REGS                       ((sdadc_registers_t*)0x42004c00)              /**< \brief SDADC Registers Address      */
#define SERCOM0_REGS                     ((sercom_registers_t*)0x42000400)             /**< \brief SERCOM0 Registers Address    */
#define SERCOM1_REGS                     ((sercom_registers_t*)0x42000800)             /**< \brief SERCOM1 Registers Address    */
#define SERCOM2_REGS                     ((sercom_registers_t*)0x42000c00)             /**< \brief SERCOM2 Registers Address    */

Names internal to the structures have changed as well, PORT register definitions gaining a PORT_ prefix and losing a level of type hierarchy:

  __IO PORT_DIR_Type             DIR;         /**< \brief Offset: 0x00 (R/W 32) Data Direction */
  __IO PORT_DIRCLR_Type          DIRCLR;      /**< \brief Offset: 0x04 (R/W 32) Data Direction Clear */

vs

  __IO  uint32_t                       PORT_DIR;           /**< Offset: 0x00 (R/W  32) Data Direction */
  __IO  uint32_t                       PORT_DIRCLR;        /**< Offset: 0x04 (R/W  32) Data Direction Clear */

This is really disturbing from a "backward compatibility" and readability point of view, even if you can "fix" it by including whatever version you want in your project (assuming you use the AS7 or MPLABX project scheme.)

Especially since I haven't seen any warnings that this was happening!

 

Also, this doesn't match either the documentation or the IO view (which doesn't quite seem to be working yet, but still...)

 

Grr.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you read the release list on packs.download.microchip.com you should see that the first 1.x version has the same header structure as the Atmel DFPs, then the version rolled to 2.x when breaking this to a MCHP header style.
.
If you want to use the old headers for SAM then use the 1.x DFP.
.
Looking at the C21, it seems to be a 2.x for old and 3.x for new.

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you read the release list on packs.download.microchip.com you should see that the first 1.x version has the same header structure as the Atmel DFPs, then the version rolled to 2.x when breaking this to a MCHP header style.

"Remove legacy headers" - such a clear and detailed explanation for such a massive change :-(

 

Start.Atmel.com is still generating "legacy" code, and it doesn't look like AS7 is downloading the "new" packs at all (still claims that 1.2.176 is the most recent for SAMC21, for example.)  Is there ever going to be convergence, or are the older tools just going to become deprecated?

 

It's not like the old names were great; I've seen cases in-the-wild where not-very-unique names in the legacy headers (PORT, WDT) end up conflicting with user #defines, causing rather mysterious errors (say, when you have "#define CONFIG xxxx" and the wdt has WDT.CONFIG...)

 

How about a backward compatibility file that does "#define PORT PORT_REGS" and so on...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've already lost all of those battles, but this is Microchip so I don't have much to say in the matter of header styles anymore...
.
If you want to complain, then support would be the correct channel (unfortunately)...
.
Doing a major rev of the DFPs on the Microchip side was the best that we got for this.
.
And no, it's unlikely that this change will be done for the DFPs for Atmel...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

Last Edited: Tue. Aug 6, 2019 - 03:41 AM