2021-06-30 03:26 AM
Hi
I have STM32F446RE and X-Nucleo-GFX01M1.
When flash my nucleo I get:
File download complete
Time elapsed during download operation: 00:00:03.366
Verifying ...
Download verified successfully
Debugger connection lost.
Shutting down...
But I cannot see anything on my screen.
Probably because when I generate the code, the SW does not modify the SPI configuration and not initialize it.
reading the following document https://www.st.com/resource/en/user_manual/dm00720406-.pdf
for me, it is not clear how should I do it. Ex: mode: full/half duplex? CPL/CPA ? CRC calculation? LED? FMARK? etc.
Thanks
Fausto
2021-06-30 07:13 AM
Debug conection lost exist when in code you use GPIO pin SWDIO SWDCLK or sleep stop standby mode and dont setup debuger for it, or when your MCU start app and this result to error for example hardfault...
2021-06-30 07:35 AM
ok, but the display is still white :)
2021-06-30 07:55 AM
Then some other issue, then.
Perhaps try some other code, and port that, perhaps looking at the settings/configuration used there.
2021-06-30 08:01 AM
X-CUBE-DISPLAY_1_0_0\Projects\NUCLEO-G071RB\Applications\GFX01M1_HelloWorld\Core\Src\stm32g0xx_nucleo_bus.c
...
/* SPI1 init function */
__weak HAL_StatusTypeDef MX_SPI1_Init(SPI_HandleTypeDef* hspi)
{
HAL_StatusTypeDef ret = HAL_OK;
hspi->Instance = SPI1;
hspi->Init.Mode = SPI_MODE_MASTER;
hspi->Init.Direction = SPI_DIRECTION_2LINES;
hspi->Init.DataSize = SPI_DATASIZE_8BIT;
hspi->Init.CLKPolarity = SPI_POLARITY_LOW;
hspi->Init.CLKPhase = SPI_PHASE_1EDGE;
hspi->Init.NSS = SPI_NSS_SOFT;
hspi->Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
hspi->Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi->Init.TIMode = SPI_TIMODE_DISABLE;
hspi->Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi->Init.CRCPolynomial = 7;
hspi->Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi->Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
if (HAL_SPI_Init(hspi) != HAL_OK)
{
ret = HAL_ERROR;
}
return ret;
}
DMA_HandleTypeDef hdma_spi1_tx;
static void SPI1_MspInit(SPI_HandleTypeDef* spiHandle)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* USER CODE BEGIN SPI1_MspInit 0 */
/* USER CODE END SPI1_MspInit 0 */
/* Enable Peripheral clock */
__HAL_RCC_SPI1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PA6 ------> SPI1_MISO
PA7 ------> SPI1_MOSI
*/
GPIO_InitStruct.Pin = BUS_SPI1_SCK_GPIO_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = BUS_SPI1_SCK_GPIO_AF;
HAL_GPIO_Init(BUS_SPI1_SCK_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = BUS_SPI1_MISO_GPIO_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = BUS_SPI1_MISO_GPIO_AF;
HAL_GPIO_Init(BUS_SPI1_MISO_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = BUS_SPI1_MOSI_GPIO_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = BUS_SPI1_MOSI_GPIO_AF;
HAL_GPIO_Init(BUS_SPI1_MOSI_GPIO_PORT, &GPIO_InitStruct);
/* Peripheral DMA init*/
hdma_spi1_tx.Instance = DMA1_Channel1;
hdma_spi1_tx.Init.Request = DMA_REQUEST_SPI1_TX;
hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_spi1_tx.Init.MemInc = DMA_MINC_ENABLE;
hdma_spi1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
hdma_spi1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
hdma_spi1_tx.Init.Mode = DMA_NORMAL;
hdma_spi1_tx.Init.Priority = DMA_PRIORITY_LOW;
if (HAL_DMA_Init(&hdma_spi1_tx) != HAL_OK)
{
Error_Handler( );
}
__HAL_LINKDMA(spiHandle,hdmatx,hdma_spi1_tx);
/* Peripheral interrupt init */
HAL_NVIC_SetPriority(SPI1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(SPI1_IRQn);
/* USER CODE BEGIN SPI1_MspInit 1 */
/* USER CODE END SPI1_MspInit 1 */
}
...