cancel
Showing results for 
Search instead for 
Did you mean: 

''Misuse'' SDIO interface to drive parallel 8bit graphics LCD?

flyer31
Senior
Posted on March 29, 2014 at 15:20

Hi,

I need an LQFP 64 device to shuffle data from an SD card to a small graphics LCD (320x240, mostly small bitmaps).

The LCD I use has a parallel data interface (standard 8bit databus with 11 connection lines: Data line 0-7 CPU, WRX signal CPU, CS signal, Data/Control signal).

All data lines are one-directional CPU -> LCD (I do NOT need to read back data from the LCD).

As the LQFP 64 devices have no FSMC interface, unfortunately I cannot handle the LCD data transfer by DMA.

But there are LQFP 64 devices with SDIO interface. As I can use the SD card in SPI mode, using an SPI interface, I thought about using the SDIO interface in 8-bit mode to shuffle the data to the LCD.

But the SDIO description in the manual is very complex. Hard for me to understand. Has anybody ever tried to use the SDIO interface in 8bit mode to shuffle out parallel data?

I would use the SDIO_CK line as /WR line for the LCD (I checked the signals, as I see it, the SDIO and LCD both use the positive edge of this control line for data write/ read, so this should work).

The LCD needs two additional control lines (/CS and /Control), but these two lines are changed only very seldom - I would just use two normal port pins for this.

PS: I would like to use the STM32F401RC (or possibly also STM32F103RC or STM32L100RC).

9 REPLIES 9
stm322399
Senior
Posted on March 29, 2014 at 15:36

AFAIK data transfers have CRC that is directly managed by the SDIO device. Only because of that it looks difficult to abuse the interface for anything else than an SDIO compatible device.

On the other side, you can drive GPIO using DMA. Say you find 11 free lines on the same port, you can encode the waveform to control you LCD in SRAM, and trigger a DMA transfer to GPIOx->ODR. It's a kind of fast bit-banging.

flyer31
Senior
Posted on March 29, 2014 at 16:59

As I see it in the STM32-SDIO examples (STM32F4xx_DSP_StdPeriph_Lib_V1.0.0 - file stm32f4xx_sdio.c), the access to SDIO there always runs through the SDIO registers SDIO->CMD and SDIO->ARG (using e. g. the commands SD_CMD_SET_BLOCKLEN and SD_CMD_WRITE_SINGLE_BLOCK to transfer some data block).

Instead I would prefer to use the control registers SDIO->FIFO (32 int block as I understand it), SDIO->DLEN and SDIO->DCTRL directly. Are you sure that then also the CRC will be calculated/transferred automatically? (Or do you think it will not be possible to access the SDIO interface on this lower level, without using the CMD/ARG register?).

Thank you for the idea with DMA to GPIO->ODR, I would not have imagined that this works - this is really an interesting idea (just it would require, that I somehow double my data in memory before DMA transfer, or I would have to use a proprietory bitmap format on the SD card with the data somehow doubled and the status of the /WR clock included in the data - this would effectively make 4 bytes out of each bitmap data byte - something not so nice of course (and of course I would prefer very much if I could write the Windows bitmap BMP data directly to the LCD, this would make life much easier, also for the users who later have to organize their BMP files...)).

Posted on March 29, 2014 at 18:11

If you synchronize the DMA with a timer, you should be able output the timer pin as the strobe, and simply BIT-BLIT the data stream to the GPIO

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Data%20transfer%20from%20GPIO%20port%20to%20RAM%20buffer%20using%20DMA%20upon%20receiving%20a%20trigger%20signal%20on%20the%20timer%20capture%2...

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
flyer31
Senior
Posted on March 29, 2014 at 19:00

What a completely ingenious information, thank you very much.

I was not aware, that you can use DMA on a timer with a memory address not belonging to the timer - so this opens the door to a complete new world.

Might I propose, that you add the following helpful hint in the reference manual in the timer ''main features'' lists, e. g. in 17.2 in STM32F4 RefMan (after the item ''Interrupt / DMA generation on the following events:...''):

''With this functionality e. g. a timer pwm can be used to strobe the DMA transfer, e. g. from memory to some GPIO port (use the GPIO ODR register as peripheral target address for the DMA timer channel. DMA2 is required, as this done by a memory-to-memory transfer).''

Thank you very much.

flyer31
Senior
Posted on March 29, 2014 at 19:24

PS: The SDIO approach also is working:

  SDIO->CLKCR= /*SDIO_CLKCR_HWFC_EN |*/ (SDIO_CLKCR_WIDBUS_0*2) | SDIO_CLKCR_PWRSAV | SDIO_CLKCR_CLKEN | ( 100);

  SDIO->DTIMER= 0xFFFFFFFF;

  SDIO->DLEN= 16;

  SDIO->DCTRL= (SDIO_DCTRL_DBLOCKSIZE_0 * 4) | SDIO_DCTRL_DTMODE | SDIO_DCTRL_DTEN;

  SDIO->FIFO= 0x04030201;

  SDIO->FIFO= 0x08070605;

  SDIO->FIFO= 0x0C0B0A09;

  SDIO->FIFO= 0x100F0E0D;

This sends out the data without CRC (In the SDIO->DCTRL assignment, it is important that SDIO_DCTRL_SDIOEN is NOT set, and the bit SDIO_DCTRL_DTMODE MUST be set - otherwise some more bytes are transferred, possibly some CRC (but it is more than 2 bytes - approximately 5-10 bytes more).

If I use the configuration as specified above, then just unfortunately the clock will start 2 bits earlier, and it will stop only about 50 bits later (And it will transfer a 0xFF as the first and last byte of the data packet). I thought of using use the SDIO_CMD line possibly as a sort of CS line, but unfortunately this fails - the SDIO_CMD line is always low during this sort of transfer.

If somebody has a hint, how to solve this with the SDIO interface, I anyway would be interested, as I think the 32 byte FIFO of the SDIO might be an advantage, if I want to operate the LCD interface at higher speed, and if several high speed DMA transfers are running in parallel. (but if this DMA stuff with the timer is working, I am perfectly happy ... I am just trying to get it run).

Posted on March 29, 2014 at 19:28

The example dealt with a condition where the DMA was externally triggered, something ST makes rather difficult. It follows from some other examples where the DMA-to-GPIO was driven internally via a timer, it that situation you could use the CHx output directly, a CHxN channel, or CHy to control a pin with the signal/placement needed.

Using the external signal is complicated a little by the use of a synchronizer on the input pin, so if things can use a common clock domain, all the better.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist
Posted on March 29, 2014 at 23:58

''Might I propose, that you (sic) add the following helpful hint in thereference manual...''

Who are you addressing as ''you''  there?

This is essentially an end-user forum - although you might  get lucky, it's unlikely that the suggestion will reach any appropriate ears within ST...

:(

jj2
Associate II
Posted on March 31, 2014 at 16:10

AWN: ''it's unlikely that the suggestion will reach any appropriate ears within ST...''

Indeed - but odds favor such suggestion first reaching appropriate eyes...  (i.e. ears signals some internal find - then ''pass-along'' communication - thus slides even further down the scale of possibility...)
FordFairlane
Associate III
Posted on April 09, 2015 at 15:27

bil.til, did you succeed controlling your LCD with SDIO or GPIO+DMA+timer?

Has anybody tried it with success?

Regards