Target is not responding, retrying... MCO set to HSI in STM32CubeIDE - NUCLEO-F303RE
I am trying to route the HSI clock to an external port of the board and so far I have got this code:
#define RCC_BASE_ADDR 0x40021000UL
#define RCC_CFGR_OFFSET 0x04UL
#define RCC_CFGR_ADDR (RCC_BASE_ADDR + RCC_CFGR_OFFSET)
int main(void)
{
uint32_t *pRccCfgrReg = (uint32_t*) RCC_CFGR_ADDR;
// Configure RCC_CFGR register MCO select HSI as a source 26:24 = 010
// Clear bits 26:24
*pRccCfgrReg &= ~(0x7 << 24);
// Set bits 26:24 to 101 HSI
*pRccCfgrReg |= ~(0x5 << 24);
/* Loop forever */
for(;;);
}
So all I am trying to do is to set MCO (Microcontroller Clock Output) bits 26:24 of the RCC_CFGR (Clock Configuration Register) to 101 which according to the manual is the HSI clock selected.
However when I execute line 12 (*pRccCfgrReg |= ~(0x5 << 24); ) in debug mode it goes into:
Download verified successfully
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Could not halt device (19)
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Failed to read registers from target
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Target is not responding, retrying...
Failed to read registers from target
Shutting down...
Exit.
Any ideas on what I am doing wrong?
