-1
$\begingroup$

I am using an STM32-L432KC microcontroller to read data from an I²C Device (Bno-055) via DMA.

On a microcontroller without DMA i would try to minimize the IO-Wait by only reading the necessary registers of the device and only reading them as often as necessary (for example the calibration status only needs to be read every second etc.).

But with DMA i am thinking about just reading the first 64 registers (that's where the information is stored) at once and store them in memory. So my library is reduced to a little bit of HAL code in the interrupt and only some defines for the values. Furthermore reading values from the sensor is nothing more than reading some values from RAM which reduces IO-Wait by a lot.

Assuming i have enough memory what are problems that occour with this solution? What are the advantages of the "traditional" approach as opposed to my approach?

$\endgroup$
  • $\begingroup$ Comments are not for extended discussion; this conversation has been moved to chat. $\endgroup$ – Mark Booth Jan 2 '18 at 15:45
  • $\begingroup$ On stack exchange, comments are not intended for extended discussions, for that use Robotics Chat. Comments are for helping to improve questions and answers, and are distracting, so we try to keep them to a minimum. Comments should be considered ephemeral, any comment which no longer actively helps to improve a question or answer may be deleted at any time to tidy up a post. $\endgroup$ – Mark Booth Jan 2 '18 at 15:46
1
$\begingroup$

DMA lets peripherals access memory directly. What component is it that is putting the information into your microcontroller's memory? It sounds like, from your post, you're having the microcontroller itself pull data on an interrupt basis. I don't think your sensor is going to push its own data to the microcontroller.

If you're having the microcontroller do all the work of getting the data into memory, then you're missing the point of DMA altogether, which may explain why this post is getting downvoted so much. If there is data you don't need then I don't understand why you would bother to acquire it, regardless of whether it's via DMA or not. You have to index the registers you want somewhere, whether that's when you pull the data from the sensor or when your program goes to read the correct data from memory.

You might be able to "speed things up" if you had a means to read I2C and then write to memory; an example would be getting a second microcontroller. The second microcontroller could then handle I2C comms and push the results directly to the memory of the first microcontroller. The first microcontroller is free to just use whatever's in memory. My concern here would be getting stale data and not realizing it's stale, or getting data mid-write.

In any event, if you don't have something that's not your primary microcontroller writing directly to memory, then whatever you're doing isn't DMA and your question doesn't really matter because you're not doing DMA.

To answer your question specifically, though,

Assuming i have enough memory what are problems that occour with this solution? What are the advantages of the "traditional" approach as opposed to my approach?

  1. Even if you have enough memory to bulk read every bit of data the sensor has to offer, you still have to get the useful data into your program. Now, instead of having a library that indexes registers on the sensor, you have to index memory in the microcontroller. Now you need a library that can access BNO055 register data in the memory of a STM32L432KC microcontroller. That is, instead of one BNO055 library, you now have a BNO055-STM32L432KC library. If you change sensors or change microcontrollers you need to re-write the library.
  2. Obviously, then, the advantage of doing it the "traditional" way is that you have a portable BNO055 library.

I'll also point out that, if the time it takes to communicate with your sensor is a deal breaker, your microcontroller doesn't have enough overhead and you should probably be looking to move to a different platform.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.