Quantcast
Viewing all articles
Browse latest Browse all 4680

SDK • Reversed bytes using DMA vs SPI display?

Hello all,

it's past 2.30 AM here so maybe I should just hit the sack already and then try to figure this out tomorrow, but here goes... Image may be NSFW.
Clik here to view.
;)


I have used SPI extensively for many things on both RP2040 and RP2350, but never attempted to hook anything up to use DMA until now. To start things off easily, I figured I could try using DMA to send data to my SPI LCD display. The display data buffer is in 16-bit RGB565 MSB first format, which is transferred to the display using 8-bit SPI transfers in sequential order. When I attempt to do this via DMA instead, the transfer as such seems to work, however while the image can be roughly perceived as there, the colours of the individual pixels seem uniformly off, except if the pixel is white (0xffff) or black (0x0000) in which case the pixel has the correct colour. I am therefore suspecting there's a simple byte reversal/flip/whatever configuration issue somewhere that I have missed, which would of course wreak havoc on RGB565, but at least at this time of day I can't figure out what it could be even after browsing through the related sections of the Pico SDK documentation. Can anyone please point me in the right direction? Image may be NSFW.
Clik here to view.
:)


Briefly summarized test case pseudo-code:

Code:

uint16_t displayBuffer[SIZE_OF_DISPLAY_BUFFER];...spi_set_format(spi0, 8, SPI_CPOL_0, SPI_CPHA_0, SPI_MSB_FIRST);...channel = dma_claim_unused_channel(true);dma_channel_config config = dma_channel_get_default_config(channel );channel_config_set_transfer_data_size(&config, DMA_SIZE_8);channel_config_set_dreq(&config, spi_get_dreq(spi0, true));channel_config_set_irq_quiet(&config, true);dma_channel_configure(channel , &config, &spi_get_hw(spi0)->dr, displayBuffer, SIZE_OF_DISPLAY_BUFFER_IN_BYTES, false);...(Pull display CS low)while (dma_channel_is_busy(channel)) sleep_us(1);dma_channel_start(channel);dma_channel_wait_for_finish_blocking(channel);...
Thanks in advance!

BR//Karl

PS EDIT: Is https://www.raspberrypi.com/documentati ... nel_config missing?

Statistics: Posted by xoblite — Fri Nov 15, 2024 1:51 am — Replies 1 — Views 40



Viewing all articles
Browse latest Browse all 4680

Trending Articles