PDA

View Full Version : Problem with DEMCR in mk20dx128.h



Bill Greiman
12-17-2012, 11:00 PM
The definition of DEMCR in mk20dx128.h as


#define DEMCR *(volatile uint32_t *)0xE000EDFC // Debug Exception and Monitor Control

conflicts with the way the symbol DEMCR is normally used in CMSIS.

This is causing problems in ChibiOS.

Normally DEMCR is define as an offset in a strut like this definition in core_cm4.h


/** \brief Structure type to access the Core Debug Register (CoreDebug).
*/
typedef struct
{
__IO uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */
__O uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */
__IO uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */
__IO uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */
} CoreDebug_Type;

and the base address is


#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */
#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */

so the register is


CoreDebug->DEMCR


It would be better if the symbol had a prefix like CORE_DEBUG_DEMCR.