Undeclared Identifier CoreDebug for STM32f446
I am creating a new project for STM32F446, and trying to access the CoreDebug registers. I am including the device header....
#include "cmsis_os2.h" // ARM::CMSIS:RTOS:Keil RTX
#include "Board_LED.h" // ::Board Support:LED
#include "Board_Buttons.h" // ::Board Support:Buttons
#include "stm32f4xx.h" // Device header
In main I try and access CoreDebug:
int main (void) {
if( CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk )
{
// Debugger is connected
}
But I get a comiler error:
RTX_Blinky.c(92): error: use of undeclared identifier 'CoreDebug'
92 | if( CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk )
RTX_Blinky.c(92): error: use of undeclared identifier 'CoreDebug_DHCSR_C_DEBUGEN_Msk'
92 | if( CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk )
This may seem simple, but I have got to here as I am trying to use EventRecorder in an RTOS2 Keil RTX5 project, and so also getting similar errors for the eventrecorder, but trying to solve the simple case hoping it will lead to solving the EventRecorder problems:
C:/Users/cider/AppData/Local/Arm/Packs/Keil/ARM_Compiler/1.7.2/Source/EventRecorder.c(1063): error: use of undeclared identifier 'CoreDebug'
1063 | CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
| ^
C:/Users/cider/AppData/Local/Arm/Packs/Keil/ARM_Compiler/1.7.2/Source/EventRecorder.c(1063): error: use of undeclared identifier 'CoreDebug_DEMCR_TRCENA_Msk'
1063 | CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
I see that Evebt Recorder uses: #include CMSIS_device_header
And so I checked that in RTE_Components.h that we have: #define CMSIS_device_header "stm32f4xx.h"
I have been through all the Options for Target, checking to see if I need to turn something on etc. Been looking at this for a few hours now, and also Googled CoreDebug etc and found the reference in the
I have checked that they exist in this micro in the STM32f446 reference manual:

Tearing my hear out over what should be something very simple that I am not seeing!
Thanks for any help in advance!
