cancel
Showing results for 
Search instead for 
Did you mean: 

Working example of stm32F446RE ADC for Nucleo board. None is given in the CubeIDE Examples. I have polling working and even interrupt but I haven't had any luck getting DMA working following examples for other F446 boards that do have ADC examples.

BBick.1
Associate II
1 ACCEPTED SOLUTION

Accepted Solutions

Thanks JW, Actually I have it working fine now. I'd missed a setting the proper channel/stream combination for my original testing, so once I worked that out from the working example that was easy to resolve in my original test code.

View solution in original post

6 REPLIES 6
TDK
Guru

DMA is just one step away from polled implementation:

  • enable DMA in RCC
  • for given DMA stream, clear status flags
  • set up source and destination pointers in M0AR (properly aligned) and PAR registers for given stream, set up number of transfers in NDTR
  • in control register, set channel, P->M direction, halfword transfer size for both sides (in direct mode the memory side is ignored anyway, but there's no harm in setting it), set interrupts (but you don't need to for initial experiments, you can simply poll the DMA status register) and enable it

Then set up ADC as you did for polling, just don't trigger it yet; set ADC_CR2.DMA, and then start the ADC triggers. You may want to experiment with manual ("software") triggering ADC first, done perhaps purely manually in debugger, while observing the NDTR register in DMA, and memory in the target buffer.

I assume you have already read the DMA-related parts of ADC chapter, and DMA chapter, in RM.

JW

Thanks TDK. I had actually tried patterning what I was doing after that example. Note that it is for a Nucleo-144 board and not forthe Nucle0-64 F446RE board that I'm working. That said I pulled the code from this example in and had to change the ADC input pin to match the MCU / board that I actually have. That is working, at least the DMA now works as it has for me with other things like DCMI on the H7xx series. The value being returned from the ADC is different than what I get with the Polling and Interrupt tests I did, so I'll need to track that issue down, but at least DMA is now working.

Thanks JW, I actually followed those steps when I was trying to integrate DMA processing from other examples from the IDE tree, but for whatever reason I couldn't get DMA to work. So I did another pass with the example listed above without trying to bring in the individual pieces, just dropped the whole code in and make the input pin change. That at least has DMA working. Now I'll go back to my original attempt to get DMA working to see what I missed.

As I said above, read out and observe the ADC and DMA registers content. To be humanly observable, make sure the ADC is triggered by a very slow time, or in some manual way. Compare registers content between working and nonworking cases.

JW

Thanks JW, Actually I have it working fine now. I'd missed a setting the proper channel/stream combination for my original testing, so once I worked that out from the working example that was easy to resolve in my original test code.