Electrical – keil v5 STM32F4 – Cannot access memory

keilstm32f4swd

I am using an STM32F407VGT board with an STLINK V2 programmer in keil IDE. I have downloaded to the board a very simple code:

#include "stm32f407xx.h"
#include <stdint.h>

int main(void)
{
  RCC_TypeDef *pRCC;
  GPIO_TypeDef *pGPIO;
  pRCC = RCC;
  pGPIO = GPIOA;

  pRCC->APB2ENR |= (1 << 0); 
  pGPIO->PUPDR = 0x11;
  return 0;
}

The problem is that when I try to enter to Debug Session, I cant use breakpoints or see the memory, the command window shows "cannot access memory". I have done the needed debug setup, even I have tried changing the parameters but I just cant´t access the memory on debug, but i do not have problems loading my code. I have also tried on Eclipse/OpenOCD and I also can download the code to the board, but it has the same issue with debugging.

This is my board
enter image description here

and this is how keil looks.

enter image description here

Best Answer

I had nearly same problem and I could solve it with the help of this.

In the debugger hardware setting window you have to explicitly select SW, otherwise the debugger will try to use the full JTAG interface for debugging. right click on your project root folder > Option for target ... > debug > use: STlink > settings > Port: SW