cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer display memory with SPI DMA

KR51K
Associate III

Hello,

I want to update my display data via SPI DMA. The display has 480x320px and I have chosen a 3 bit color coding, so that I can send two pixel within one byte. So my framebuffer has a size ox (480x320)/2 = 76800 byte. But when I want to transmit them with

HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)

I have the size restriction. Do you have any idea how to solve this? I tried to use a state machine within the Interrupt:

	switch ( eSpiDMA_TransmissionState )
	{
		case eStartTransmission:
			LCD_CS_SET;
 
		    LCD_DC_RESET;
		    LCD_CS_RESET;
		    eSpiDMA_TransmissionState = eSendFirstHalf;
		    if ( HAL_SPI_Transmit_DMA( &hspi2, (uint8_t *)0x2c, 1 ) != HAL_OK)
		    {
		    	// todo: error handling
		    }
 
			break;
		case eSendFirstHalf:
			LCD_CS_SET;
 
			LCD_DC_SET;
			LCD_CS_RESET;
			eSpiDMA_TransmissionState = eSendSecondHalf;
			if ( HAL_SPI_Transmit_DMA( &hspi2, &displayFramebuffer[0], 38400U ) != HAL_OK)
			{
				// todo: error handling
			}
 
			break;
		case eSendSecondHalf:
			eSpiDMA_TransmissionState = eStartTransmission;
			if ( HAL_SPI_Transmit_DMA( &hspi2, &displayFramebuffer[38400U], 38400U ) != HAL_OK)
			{
				// todo: error handling
			}
			break;
	}

But this doesn't work (it seems that the display is updated in 4 instead of 2 parts), and doesn't update afterwards ( I change the color in another task every 500ms, but the display color doesn't change).

Any ideas for this?

3 REPLIES 3
TDK
Guru

Set it up to transmit half or full words instead of bytes. That way the number of transfers is below 65536. I know the peripheral will allow this. Pretty sure HAL will do it too.

If you feel a post has answered your question, please click "Accept as Solution".
KR51K
Associate III

Hello,

unfortunately I have some problems getting the display running when running in 16bit mode (can't find out why since I don't have an oscilloscope).

KR51K
Associate III

I tried to build a union with the 8 bit framebuffer array (that's easier for me with my graphical lib) and a 16bit array for dma. After the configuration of the display I sitched to 16bit SPI and tried to send the data:

	hspi2.Init.DataSize = SPI_DATASIZE_16BIT;
	if (HAL_SPI_Init(&hspi2) != HAL_OK)
	{
		Error_Handler();
	}
	LCD_CS_RESET;
	LCD_DC_SET;
	HAL_SPI_Transmit_DMA( &hspi2, (uint8_t*)imageFramebuffer.displayFramebuffer16Bit, 38400U );

but it only sends the data as 8 bit (every second pixel is blank, image is streched).

Do you have any idea?