cancel
Showing results for 
Search instead for 
Did you mean: 

FSMC and DMA causing dma error

giles
Associate II
Posted on December 09, 2008 at 11:34

FSMC and DMA causing dma error

13 REPLIES 13
giles
Associate II
Posted on May 17, 2011 at 12:51

Hi, we're using the STM32F103ZCT6 and with the FSMC to comumicate to an SRAM chip (CY7C1041DV33).

under normal operation writing in a loop it writes and reads correctly,

using dma alone it operates correctly.

However if a dma operation is in progress writing to the sram chip and we do a normal write to a memory location on the sram chip or vice versa we get a dma error.

Anyone have any ideas, i've tried relaxing timings and running it flat out, either way it works unless the 2 operations occur at once.

16-32micros
Associate III
Posted on May 17, 2011 at 12:51

Dear giles,

Could you please explain what is the DMA error you have seen ? and also what is the test you performed in ''Normal write'' is it by CPU or using Debugger windows ? Do you write or read to the same memory location ? It would be helpful if you post a piece of code that I can reproduce the same with my Evaluation board and let you know if I can help.

Cheers,

STOne-32.

giles
Associate II
Posted on May 17, 2011 at 12:51

Hi STOne,

Using the cpu to trigger it - not the debugger. (We're not using the eval board but our own prototype).

To cause the error we set up the dma to write from an array (internal stm32 memory) to External SRam, with : Transfer Complete Interrupt Enabled and Transfer Error Interrupt Enabled.

When the interrupt triggers 'complete' we reload the dma and set it going again, same array, 10 bytes, same target(0x68000000). If it errors we have a while(1) to catch it there - crude i know but it works.

While this is going on in the main loop we have:

while(1)

{

a1 = (a1 +4) & 0xFFFF;

*((unsigned int *)(0x68000000 +a1)) = 0x123456;

};

Both the while loop and the DMA work on their own, (if I comment the write in the while loop it works, or if I comment the dma enable line it works)

but together it gets stuck in the while loop.

(the sram is on bank3, its just a crude example project demonstrate the problem - on the main project we're using an ethernet chip on bank2, sram on 3 and sram on 4. We first saw the problem working between the ethernet chip and the sram, in the crude example we're not using the second sram or ethernet chip so they're not causing the problem)

Thanks,

Giles

[ This message was edited by: giles on 07-11-2008 09:57 ]

tibo
Associate II
Posted on May 17, 2011 at 12:51

two hints to surround the problem:

- don’t write to the same address with the dma controller and the cpu.

- if you have a 16-bit SRAM write only half-words (or bytes for 8-bit SRAM) with the

dma controller and the cpu (the FSMC translates a 32-bit access in two or more

accesses to external 16-bit (or 8 bit) devices).

giles
Associate II
Posted on May 17, 2011 at 12:51

Good point but sadly that didn't help.

It does it writing to different addresses on the xram with the dma writing bytes and the main loop writing (16 bit) unsigned shorts.

(i changed my test to check what you suggested)

More concerningly the error occurs when writing chars with dma, and reading (shorts) in the main loop (not writing to xram in the main loop, just reading it there) - even with different memory locations for read and write.

Both Read and write work individually in the main or dma its just both at once thats the problem.

any ideas?

[edit]

Just tried a slightly different test -

writing to one chip(dma) and reading from another(main loop), the error still occurs.

[ This message was edited by: giles on 10-11-2008 10:46 ]

giles
Associate II
Posted on May 17, 2011 at 12:51

STOne, i have knocked up a sample project, based off our project that demonstates the problem on the STM3210E-Eval board

Regards

Giles

16-32micros
Associate III
Posted on May 17, 2011 at 12:51

Hi Giles,

I'm able to see the case on my board and when I get the error it is a HardFault. This is happening only when DMA Memory to Memory and Circular modes are enabled. is it the same for you ? If I disable Circular mode I have no issues. Now looking at RM0008 ( Reference Manual) I see a note that Memory to Memory Mode and Circular modes should not be used together in general, so It seems we are out of DMA specification.

Let me know your results. Cheers,

STOne-32.

giles
Associate II
Posted on May 17, 2011 at 12:51

Hi STOne-32

I'm afraid i'm not using circular mode.

Its not showing up as a hard fault for me, in my test app its showing up as just a DMA Transfer Error, on our actual project using it we were seeing bus faults.

(See the example i attached on the previous post for my exact settings 🙂 )

Thanks for your continued assistance

Cheers

Giles

tibo
Associate II
Posted on May 17, 2011 at 12:51

hi ST1,

which situation will trigger the dma error interrupt? I found no info's in the documentation

about this point.