2024-01-08 06:19 AM
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!
2024-01-08 06:40 AM - edited 2024-01-08 06:41 AM
CoreDebug is defined in core_cm4.h which is included from stm32f446xx.h provided you have the correct define set up for your processor. Should be a definition of STM32F446xx or similar.
2024-01-08 07:55 AM
Thank you for your response TDK. I do have core_cm4.h...
But it does not include 'CoreDebug' - I can see the register definitions, but different from the code sample I posed above, and as what is used in EventRecorder.c :
if( CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk )
Where as in my core_cm4 I have the debug enable mask defined as:
#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */
#define DCB_DHCSR_C_DEBUGEN_Msk (1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */
so the core_cm4.h that I have is not using the 'CoreDebug...' syntax that is being used by EventRecorder.c. I searched for @CoreDebug' in the core_cm4.h file, there were no matches, as can be seen in the above screenshot.
Thanks for any help you can give, I am tearing what's left of my hair out!
2024-01-08 08:01 AM
Also just found this relating to different cores:
But should I change my readonly files EventRecorder.c? I am not sure how you even go about changing a readonly file, do I have to do it outside the IDE?
2024-01-08 08:20 AM
The CoreDebug definition is in the latest core_cm4.h file in the Cube repository.
I don't know where your file came from, but if it doesn't have CoreDebug, and you need it, update your library files to the latest version.
Typically this requires replacing all files, but it's possible you can get away with only replacing core_cm4.h.
2024-01-08 08:41 AM
Thank you again TDK. I was trying to avoid using the STMcube or MX at all. and so this is the file provided by ARM/Keil : C:\Users\myuser\AppData\Local\Arm\Packs\ARM\CMSIS\6.0.0\CMSIS\Core\Include\core_cm4.h
It's bad form that there are such differences between the two versions!
I'll go and make a CubeMX project and then add in the RTX5 from Keil once I set up the project, and let you know how I get on.
2024-01-08 10:00 AM
I have now uninstalled MDK539 and all its packs etc and went back to MDK538a. There I can copy the example project for the nucleo board I have, and change over to RTOS2 and in the RTE select the EventRecorder and not it will compile ok!
C:\Users\cider\AppData\Local\Arm\Packs\ARM\CMSIS\5.9.0\CMSIS\Core\Include\core_cm4.h from CMSIS 5.9 contains:
So it seems that Arm/Keil are moving from CoreDebug to DCB from thier move from CMSIS 5.9 to 6, but the EventRecorder.c is still looking for CoreDebug!