Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 3 months ago.
SimpleDMA with SPI on KL25Z
Hi - this is more of an answer than a question, but I thought I'd post it in the form of a question so that (a) it's a valid Jeopardy response and (b) it's recorded here for other people who might run into the same issue.
If you want to use SimpleDMA to send output to an SPI controller on the KL25Z, you need to explicitly enable DMA on the SPI controller. This is done by setting TXDMAE == bit 5 == 0x20 in the SPI control register 2:
SPI0->C2 |= 0x20;
Just do this once when setting up the controller (I do it at the same time where I set up my buffer pointers).
It might be nice if SimpleDMA could do this automatically, but I suppose that might be at odds with the "simple" part design-wise.
Question relating to:
1 Answer
9 years, 3 months ago.
Just to answer the answer: Indeed, SimpleDMA only does the part of the DMA controller, and not at the other side. On one hand you are correct that there is definately something to say for also setting the SPI/UART/etc correct when this is set as trigger for the DMA. On the other hand you can also say that that is outside the responsibility of the DMA code.
Overall I think your idea to do it automatically might be the better one, but also currently it is not in the planning to change it for SimpleDMA :). So for others finding your answer: Assuming it does not change, you indeed need to manually set the correct bits in the peripheral to generate DMA requests :). (In the example code you can for example see how to do it for an UART).