cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U575 GPDMA1 Configuration Problem

Sany
Associate III

Hello,

I have a board with a STM32U575RGTX CPU, and i use SPI1 with a 2.8" TFT ILI9341 Display.
I got problems with the GPDMA1 configuration, and need help.

main.c:

 

 

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_GPDMA1_Init();
  MX_CRC_Init();
  MX_TIM2_Init();
  MX_SPI1_Init();
  MX_ICACHE_Init();
  /* USER CODE BEGIN 2 */

  _lcd = ili9341_new(&hspi1, LCD_RESET_GPIO_Port, LCD_RESET_Pin, LCD_NSS_GPIO_Port, LCD_NSS_Pin, LCD_DC_GPIO_Port, LCD_DC_Pin, isoLandscape, LCD_CS_GPIO_Port,LCD_CS_Pin, LCD_IRQ_GPIO_Port, LCD_IRQ_Pin, itsNONE, itnNormalized);
  ili9341_fill_screen(_lcd, ILI9341_RED); // FILL SCREEN RED
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

 

 

ILI9341:

 

 

void ili9341_fill_screen(ili9341_t *lcd, ili9341_color_t color)
{
  ili9341_fill_rect(lcd, color,
      0, 0, lcd->screen_size.width, lcd->screen_size.height);
}

void ili9341_fill_rect(ili9341_t *lcd, ili9341_color_t color,
    int16_t x, int16_t y, uint16_t w, uint16_t h)
{
  // verify we have something within screen dimensions to be drawn
  if (ibNOT(ili9341_clip_rect(lcd, &x, &y, &w, &h)))
    { return; }

  uint32_t num_pixels = w * h;
  uint32_t rect_wc    = num_pixels;

  uint32_t block_wc = rect_wc;
  if (block_wc > __SPI_TX_BLOCK_MAX__)
    { block_wc = __SPI_TX_BLOCK_MAX__; }

  // fill entire block with ordered color data
  uint16_t color_le = __LEu16(&color);
  for (uint16_t i = 0; i < block_wc; ++i)
    { spi_tx_block[i] = color_le; }

  // select target region
  ili9341_spi_tft_set_address_rect(lcd, x, y, (x + w - 1), (y + h - 1));
  ili9341_spi_tft_select(lcd);

  HAL_GPIO_WritePin(lcd->data_command_port, lcd->data_command_pin, __GPIO_PIN_SET__);

  // repeatedly send MIN(remaining-words, block-words) words of color data until
  // all rect words have been sent.
  uint32_t curr_wc;
  while (rect_wc > 0) {
    curr_wc = rect_wc;
    if (curr_wc > block_wc)
      { curr_wc = block_wc; }
    ili9341_transmit_color(lcd, curr_wc * 2/*16-bit words*/, spi_tx_block, ibYes);
    rect_wc -= curr_wc;
  }

  ili9341_spi_tft_release(lcd);
}

void ili9341_transmit_color(ili9341_t *lcd, uint16_t size, uint16_t color[]/* already byte-swapped (LE) */, ili9341_bool_t wait)
{
  if ((NULL == lcd) || (0 == size) || (NULL == color))
    { return; }
  HAL_SPI_Transmit_DMA(lcd->spi_hal, (uint8_t *)color, size);
  if (ibOK(wait))
    { ili9341_transmit_wait(lcd); }
}

 

 

When i use HAL_SPI_Transmit_DMA, then the colors on the TFT are not correct (Red=Magenta,Green=Green,Blue=Black), if i change the code to HAL_SPI_Transmit without DMA, then the colors are correct... what can be wrong in my DMA Config?

Here is my config:

spi1.pngspi2.pngspi3.png

SPI is configured with 8-Bit and MSB.

0 REPLIES 0