SDHC working with DMA

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

SDHC working with DMA

12,641 次查看
jocelyn_massero
Contributor II

Hi,

 

I'm trying to develop a program which communicatee with WIFI card over SDIO protocol. The SDIO protocol part working fine but I want to use the simple internal DMA to read and write data. However I got at every time a DMA ERROR interrupt (the DMA TRANSFER COMPLETE flag is also fired up). Here is my configuration program:

 

SDIO_SetWriteWatermark(SDHC_BASE_PTR, (u32)(count&0xffff));SDIO_SetReadWatermark(SDHC_BASE_PTR, (u32)(count&0xffff));SDIO_SetDMAAddress(SDHC_BASE_PTR, (u32)data); // data is an pointer over my bufferSDIO_SetCommandArgument(SDHC_BASE_PTR, arg); SDIO_SendCommand(SDHC_BASE_PTR, SDIO_CMD53_IO_RW_EXTENDED,SDIO_ENABLE_DMA |                                                         SDIO_DATA_PRESENT |                                                         SDIO_DATA_READ |                                                        SDIO_RESPONSE_LENGTH_48);

 

Someone has an idea to get the SDIO working fine with the internal DMA?

 

Thanks,

 

Jocelyn

37 回复数

4,206 次查看
T_M_F
Contributor I

Can you send you code for me to test on my SDIO WIFI card?

0 项奖励
回复

4,214 次查看
mjbcswitzerland
Specialist V

Hi Jocelyn

 

I didn't manage to get ADMA working on the SDIO. The problem that I had was that I was getting data from the chip (visible with logic analyser) but the ADMA2 was giving an error that its buffer descriptor was invalid (DMA error).

 

Its buffer descriptor is very simple and I didn't see why it should report that the valid bit is not set (even if I filled the buffer descriptor with 0xffffffff 0xffffffff it reported the same error, even though no bit is a '0'...(?)). Therefore I always used it since then in non-DMA mode.

 

Is this a different problem to yours or is it effectively the same?

 

Regards

 

Mark

 

0 项奖励
回复

4,214 次查看
jocelyn_massero
Contributor II

Thanks for your reply,

Yes I have the same error as yours when I use ADMA2. That's really weird because the descriptor seems to be correct. I also tried the simple DMA mode and I have also a DMA error.

Hope that someone will can help us.

Regards

Jocelyn

0 项奖励
回复

4,214 次查看
mjbcswitzerland
Specialist V

Hi Jocelyn

 

I haven't found any examples on this so I am assuming that it doesn't work (rather than invest too much time getting no where). It would ceretainly be good if freescale could add a demonstration in this mode to know that it will be worth making the attempt to overcome difficulties, whereby I would expect that the trick to getting it working will be visible in the example.

 

It may be due to ADMA access rights but I didn't find what may be controlling it - in which case the actual DMA error may be misleading (eg. if the DMA controller can't actually access the buffer descriptor). In other DMA cases it sometimes occurs that there is a problem with access rights but I have otherwise always found that the DMA error made this fairly clear....

 

Regards

 

Mark

 

0 项奖励
回复

4,214 次查看
jocelyn_massero
Contributor II

Hello,

 

Try to desactivate the MTU protection on the kinetis, that solved my problem. Now the DMA can access to the memory.

 

Regards,

 

Jocelyn

0 项奖励
回复

4,214 次查看
Gargy
NXP Employee
NXP Employee

Hi,

 you are absolutely right, with one mistake.

The name of protection is not MTU, but MPU.

 

// Switch off MPU unit
    MPU_CESR &= ~MPU_CESR_VLD_MASK;

 

Gargy

0 项奖励
回复

4,214 次查看
Muffinman
Contributor I

Thanks Gargy,

 

Did you test the speed with the DMA foe esdhc 4 bit?

0 项奖励
回复

4,214 次查看
Gargy
NXP Employee
NXP Employee

Hi,

not yet. This is my hobby project and I don't have enough time for it :smileysad:.

 

Gargy

0 项奖励
回复

4,214 次查看
T_M_F
Contributor I

Gargy,

 

What code are you guys talking about, where can I find it?

 

Thanks!

0 项奖励
回复

4,214 次查看
Gargy
NXP Employee
NXP Employee

Hi I wrote, one pcs of driver myself, but still there is any bug. When I stepping the code, it runs but if I run the code the MCU broke down. :smileyhappy:

 

Gargy

0 项奖励
回复

4,214 次查看
Muffinman
Contributor I

The naked speed for the 4 bit SDIO for 100M Hz K60 could be around 40-50M bps. I didn't know if your driver is ready for so fast buffer transceiving? Could you send me the driver for my reference. My email is in theis topic.

0 项奖励
回复

4,214 次查看
Gargy
NXP Employee
NXP Employee

Hi,

 maybe I just have the developing version (not finished), but why not. More eyes, more see.

 

I will send it to you when I will be on my home PC.

 

 

Gargy

0 项奖励
回复

4,214 次查看
Muffinman
Contributor I

I didn't receive the code, would you like send again?

 

0 项奖励
回复

4,214 次查看
Gargy
NXP Employee
NXP Employee

Hi,

 you can't received anything, because I didn't sent you email. Give me few days (up to weekend). I have at the moemnt something function but I want to clear up little bit source code.

 

Please be more patient.

I looks that it will be works.

 

Gargy

0 项奖励
回复

4,214 次查看
Gargy
NXP Employee
NXP Employee

Hi,

 here is my testing project for TWR-K60. It runs on mask 0M33Z. I tested it in IAR 6.21.


So I hope that will help zou, and I also except that zou look inside and all possible bugs or improvements zou are placed on this forum(I'll be more than happy) .

 

So there is also tested file system FATFS (http://elm-chan.org/fsw/ff/00index_e.html).

The driver is designed just only for SD/SDHC cards.

 

Enjoy and let me know.

Gargy

0 项奖励
回复

4,205 次查看
Masmiseim
Senior Contributor I

Hello,

sorry for bringing this Thread back to live.

@

0 项奖励
回复

4,204 次查看
Gargy
NXP Employee
NXP Employee

Hello,

here is the original version that I did in past (probably same as I left it at last time).version of MQX driver based on DMA and interrupts

In these days I did new MQX version of SDHC driver based on DMA and interrupts and I was able to achive on one card with MFS (MQX File system) read speed about 17MB/s.

So this driver is little bit obsolete, but it helps as a start point.

Petr

4,204 次查看
Masmiseim
Senior Contributor I

Hey,

thanks fort he code,

I got it running with my Rowley Compiler and it seems to work correct. This is a good reference.

I tried to use the ADMA2 for Data-transfer and was unable to transfer a single Byte. I think I can manage it with this reference

Thanks and Regards


0 项奖励
回复

4,205 次查看
Gargy
NXP Employee
NXP Employee

Hi, good to hear that code is running.

I'm sorry to say this but you want be able to read/write only one byte by ADMA due to SDHC peripheral errata  - check the document.

The data buffers MUST be aligned to 4 bytes and also the length must be greater than 4 bytes  and aligned to 4 bytes.

Petr

0 项奖励
回复

4,205 次查看
Masmiseim
Senior Contributor I

Sorry, for the confusion. I want to read a complete sector over SDIO (512 Byte) but get only an Interrupt with  DMAE and CRM Flags in the IRQSTAT Register. Receiving the CID and CSD worked fine.

Your Code gives my some hints where I could change some settings.


0 项奖励
回复