Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.

We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.

Thank you for your understanding.


This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cannot debug project because of Cannot access target error

Dear Sirs and Madams!

I am having problems debuging following code:

void ueInitLCD(void)
{
    // Initialization structures
    I2C_InitTypeDef ueI2C_NCP5623_InitStructure;
    SPI_InitTypeDef ueSPI_DOGM128_InitStruct;
    GPIO_InitTypeDef ueGPIO_DOGM128_I2C_InitStruct;
    GPIO_InitTypeDef ueGPIO_DOGM128_CS_InitStruct;
    GPIO_InitTypeDef ueGPIO_DOGM128_RST_InitStruct;
    GPIO_InitTypeDef ueGPIO_DOGM128_A0_InitStruct;

    // Initialize IC2 Bus
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1,
        ENABLE);
    ueI2C_NCP5623_InitStructure.I2C_Mode = I2C_Mode_I2C;
    ueI2C_NCP5623_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
    ueI2C_NCP5623_InitStructure.I2C_OwnAddress1 = 0x70;
    ueI2C_NCP5623_InitStructure.I2C_Ack = I2C_Ack_Enable;
    ueI2C_NCP5623_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
    ueI2C_NCP5623_InitStructure.I2C_ClockSpeed = 400000;
    I2C_Cmd(I2C1,
        ENABLE);
    I2C_Init(I2C1,
        &ueI2C_NCP5623_InitStructure);

    // Configure GPIO pins for I2C use
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,
        ENABLE);
    ueGPIO_DOGM128_I2C_InitStruct.GPIO_Pin = UE_PIN_DOGM128_SPI_CLK | UE_PIN_DOGM128_SPI_SI;
    ueGPIO_DOGM128_I2C_InitStruct.GPIO_Mode = GPIO_Mode_AF_OD;
    ueGPIO_DOGM128_I2C_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(UE_PORT_DOGM128_SPI,
        &ueGPIO_DOGM128_I2C_InitStruct);

    // Initialize SPI
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1,
        ENABLE);
    ueSPI_DOGM128_InitStruct.SPI_Direction = SPI_Direction_1Line_Tx;
    ueSPI_DOGM128_InitStruct.SPI_Mode = SPI_Mode_Master;
    ueSPI_DOGM128_InitStruct.SPI_DataSize = SPI_DataSize_8b;
    ueSPI_DOGM128_InitStruct.SPI_CPOL = SPI_CPOL_High;
    ueSPI_DOGM128_InitStruct.SPI_CPHA = SPI_CPHA_2Edge;
    ueSPI_DOGM128_InitStruct.SPI_NSS = SPI_NSS_Soft;
    ueSPI_DOGM128_InitStruct.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
    ueSPI_DOGM128_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;
    SPI_Init(UE_PERIPHERAL_DOGM128_SPI,
        &ueSPI_DOGM128_InitStruct);
    SPI_Cmd(UE_PERIPHERAL_DOGM128_SPI,
        ENABLE);

    // Initalize GPIO (CS - Chip Select)  Pin
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,
        ENABLE);
    ueGPIO_DOGM128_CS_InitStruct.GPIO_Pin = UE_PIN_DOGM128_CS;
    ueGPIO_DOGM128_CS_InitStruct.GPIO_Mode = GPIO_Mode_Out_OD;
    ueGPIO_DOGM128_CS_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOA,
        &ueGPIO_DOGM128_CS_InitStruct);

    // Initialize GPIO (RST - Reset) Pin
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,
        ENABLE);
    ueGPIO_DOGM128_RST_InitStruct.GPIO_Pin = UE_PIN_DOGM128_RST;
    ueGPIO_DOGM128_RST_InitStruct.GPIO_Mode = GPIO_Mode_Out_OD;
    ueGPIO_DOGM128_RST_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOC,
        &ueGPIO_DOGM128_RST_InitStruct);

    // Initialize GPIO (A0) Pin
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,
        ENABLE);
    ueGPIO_DOGM128_A0_InitStruct.GPIO_Pin = UE_PIN_DOGM128_A0;
    ueGPIO_DOGM128_A0_InitStruct.GPIO_Mode = GPIO_Mode_Out_OD;
    ueGPIO_DOGM128_A0_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOD,
        &ueGPIO_DOGM128_A0_InitStruct);

    GPIO_WriteBit(UE_PORT_DOGM128_CS,
        UE_PIN_DOGM128_CS,
        Bit_RESET);
    GPIO_WriteBit(UE_PORT_DOGM128_RST,
        UE_PIN_DOGM128_RST,
        Bit_SET);
    GPIO_WriteBit(UE_PORT_DOGM128_RST,
        UE_PIN_DOGM128_RST,
        Bit_RESET);

    lcdSendCommand(lcdInitCmd,
        sizeof(lcdInitCmd));
}   // ueInitLCD

void lcdSendCommand(const char *pcCmd,
    uint8_t ui8Len)
{
    uint16_t index = 0;

    for(index = 0; index < ui8Len; index++)
    {
        SPI1->DR = pcCmd[index];
        while (!(SPI1->SR & SPI_I2S_FLAG_TXE));
        //while (!(SPI1->SR & SPI_I2S_FLAG_RXNE));
        while (SPI1->SR & SPI_I2S_FLAG_BSY);
    }
}   // lcdSendCommand


When I press Ctrl+F5 to debug upper functions, I get following error:

Cannot access Target. Shutting down debug session.

However, I can download compiled code to target board without problems. Why is this happening?

Parents Reply Children
  • Indeed, you are right, forgot to attach pin mappings, here they are now:

    #ifndef ARCHITECTURE_H
    #define ARCHITECTURE_H
    
    #include "stm32f10x_conf.h"
    #include "stm32f10x_spi.h"
    #include "stm32f10x.h"
    
    // ~CS (Chip Select) Pin Mapping
    #define UE_PORT_DOGM128_CS  GPIOA
    #define UE_PIN_DOGM128_CS   GPIO_Pin_15
    
    // RST (Reset) Pin Mapping
    #define UE_PORT_DOGM128_RST GPIOC
    #define UE_PIN_DOGM128_RST  GPIO_Pin_12
    
    // A0 Pin Mapping
    #define UE_PORT_DOGM128_A0  GPIOD
    #define UE_PIN_DOGM128_A0   GPIO_Pin_2
    
    #define UE_PERIPHERAL_DOGM128_SPI       SPI1
    
    #define UE_PORT_DOGM128_SPI             GPIOB
    
    // SPI CLK (SPI Bus Clock) Pin Mapping
    #define UE_PIN_DOGM128_SPI_CLK          GPIO_Pin_3
    
    // SPI SI (MOSI) Pin Mapping
    #define UE_PIN_DOGM128_SPI_SI          GPIO_Pin_5
    #endif
    

  • PB3 is the JTDO/TRACESWO pin
    PA15 is the JTAG JTDI pin

    You might want to do a partial remap based on whether you are using SWD or JTAG connectivity