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
No data