cancel
Showing results for 
Search instead for 
Did you mean: 

Using SPI with DMA

BTurc.2
Senior

Hi All, I'm using an STM32F1 with a 240x240 LCD screen that comunicates with the micro by SPI (with DMA). The screen uses the ST7789 driver (I supose it is not important). I'm working with RGB565 color format.

The problem that I have is, for example, when I'm using the ST7789_Fill_Color(YELLOW); the SPI uses the DMA and the LCD shoul be yellow but it's not. If yellow is 0b1111 1111 1110 0000 the DMA only sends to SPI the LSB (0b0000 0000 1110 0000) witch is a wrong color.
When I do the same without DMA it work's fine!

The DMA is configures this way:

BTurc2_0-1688298032648.png

I tried every configuration possible but nothing works. My question is why the DMA only graps the first byte of a color and what I have to change in order to send the real color.

Thanks in advance!!!

 

21 REPLIES 21
Jeffrey0567
Associate

Hello BTurc.2, I have same problem with you. This is my fixed part, and it's work well with my stm32f401.

Hope this helps.

 

void ST7789_Fill_Color(uint16_t color)

{

uint32_t i,color_convert;

uint16_t disp_buf_size=ST7789_WIDTH * HOR_LEN;

ST7789_SetAddressWindow(0, 0, ST7789_WIDTH - 1, ST7789_HEIGHT - 1);

ST7789_Select();

 

#ifdef USE_DMA

color_convert=(color<<11) | ((color>>11)<<6) | ((color<<5)>>10);

for (uint32_t i=0;i<disp_buf_size;i++) {

disp_buf[i]=color_convert;

}

 

for (i = 0; i < ST7789_HEIGHT / HOR_LEN; i++)

{

// memset(disp_buf, color, sizeof(disp_buf));

 

ST7789_WriteData((uint8_t *)disp_buf, sizeof(disp_buf));

 

}

#else

uint16_t j;

for (i = 0; i < ST7789_WIDTH; i++)

for (j = 0; j < ST7789_HEIGHT; j++) {

uint8_t data[] = {color >> 8, color & 0xFF};

ST7789_WriteData(data, sizeof(data));

}

#endif

ST7789_UnSelect();

}

 

 

Hi all, about last reply that function sometime has wrong color. Then, I used logic analyzer and find out my dma spi output data is shift 1 bit : 1 111111011100100 become 111111011100100 1. i will still research.....