2012-09-10 02:52 AM
Hi all,
Coming from AVR 8 bits architecture, I plan to work (hard) to develop an IMU under STM32F405xx now.I'd like to know if the following architecture is correct. I believe it's possible from my first readings of datasheet, application notes and examples from ST, but I'd like a confirmation.And of course I would need to analyze example code to start my work on. So I would be very glad if you can advise me some examples or application note for each separate function I need :Hardware drivers through DMA to save CPU :- continuous usage of SPI1 through DMA- continuous usage of SPI3 R/W on SD card through DMA- continuous usage of I2C1 through DMA 400 KHz (is it possible at higher frequency too ?)- continuous usage of I2C2 through DMA 400 KHz- continuous usage of UART6 through DMA- Hard Interrupt from an INPUT GPIO (rising edge only), and from the same source signal, an Input Capture to access accurate duration between each change (Rising only too)- Soft Interrupt from an overflow timer (low frequency : max 4000 Hz) - ADC readings for a joystick, low criticality, low frequency, so I believe without DMA is possible- Input pin reading level (for a button), low criticality, so without interrupt- 4x PWM OutputsAnd of course with the FPU enabled to do great maths with, at the maximum update frequency !Especially, do you know a tutorial to discover DMA, because it seams to be quite different from the INTERRUPT VECTORS from the 8bits AVR architecture, especially concerning priority of the different interrupts ? Application notes are not exhaustive at the moment for F4, and I don't know if I can use others from other like STM32F1...So I would appreciate a lot every advise, example or warning before I begin my work, So thanks a lot ;) #stm32f405xx-dma-spi-i2c-fpu2012-09-10 06:31 PM
Read the reference manual ADC section before concluding DMA is not required. Each ADC has one conversion results register. Converting even 2 or 3 channels is typically done using DMA and one ADC.
In the reference manual DMA section, there is a table of DMA channels vs peripherals. That defines constraints that will probably affect your design. Cheers, Hal2012-09-10 10:54 PM
In the reference manual DMA section, there is a table of DMA channels vs peripherals. That defines constraints that will probably affect your design.
And don't forget the errata sheet. There is a limitation for DMA2 at certain simultaneous transfers.
2012-09-11 03:42 AM
Thanks both of you for you answers : it appears I have to choose the appropriate schem, that's true.
Just one point : about my needing of a simple timer overflow interrupt at a fixed frequency : is it necessary to use a DMA request (like a TIM1_TRIG for this overflow) ?I read I can use an update interrupt instead ?What is the main difference between that both ways of interrupting please ?About the Hard interrupt from a single GPIO : I can use an interrupt not interferring with the DMA usage, is that true ?What about priority between DMA and other interrupt vectors ?About the error in DMA2 : I can read :WorkaroundAvoid concurrent AHB (DCMI, CRYPTO, HASH, FSMC with external FIFO) and APBtransfer management using the DMA2.It should be OK, because I'm not using DCMI, CRYPTO, HASH, but I don't understand well what is exactly ''External FIFO controlled by the FSMC''. In what typical case are this function used please ?Thanks again2012-09-11 04:57 AM
FSMC is the external memory interface for RAM, FLASH and LCD panels.
You might not need it, too. But here in this forum, and otherwhere, are still threads discussing this DMA2 issue at length. (Well, with the update of this forum software, there might something got lost here ...) For the other questions, at first glance I would generally answer - yes. I suggest to wait for a rainy/boring weekend, and swallow the Reference Manual for the controller you intend to use. All your questions are answered there in detail. You might want the datasheet as well, which bears information about the pinout, pin assignments and electrical data.2012-09-11 08:54 AM
Thanks again FM,
Another 2 (last ???) questions.- Can we use I2C, SPI, USART interrupt requests without the DMA ? If any problem is encounter with DMA, perhaps I should begin by there.- It appears the STM32F4xx_StdPeriph_Examples are not complete at the moment (perhaps because of this DMA2 problem). So would it be a good practice to have a look at STM32F10x_StdPeriph_Examples ?Are there many common registers and functions ?Of course I will deeply investigate manual and datasheets, but it's always good to hear about what other experienced users can warn before going onto the same kind of problem. DMA2 is a good example.Thanks for your help2012-09-11 09:38 AM
So would it be a good practice to have a look at STM32F10x_StdPeriph_Examples ?
While they have some value, I would be generally cautious as the GPIO pin configurations and alternate function mapping are very different. The architecture has evolved quite significantly. The old v1.xx and v2.xx libraries, pre-CMSIS had some more complete examples, as I recall. As a reference they will be helpful, but don't expect to cut-n-paste code, they will need a considered reinterpretation. I'd stick to the F2 and F4 firmware examples, and also the code in the DSP and USB library examples. It's good to collect all the available code so you can reference and search it as required. The web site is a bit messy, so it's often hard to find things you know are there, but buried under some tab, or some specific part. Googling specific functions, or parameters, can often pull up third party examples which can often demonstrate more integrated behaviour than the singular focus of some of the ST examples.And of course with the FPU enabled to do great maths with, at the maximum update frequency ! The FPU only supports 32-bit floats, with the limited precision they bring. Consider the pitfalls of floating point math in general, and that it doesn't hold intermediate values at significantly higher precision like it would on a PC/MAC. In that regard it's not that great, and significantly lamer than a 1980's 8087 implementation.2012-09-11 12:17 PM
Well, Clive is certainly correct.
There are STM32F2 and STM32F4 examples available, which should be your first choice. And regarding floating point precision, I guess you knew that... But the performance should be sufficient to do rather complex calculations at realtime, say, at a cycle of a few milliseconds for an IMU.- Can we use I2C, SPI, USART interrupt requests without the DMA ? If any problem is encounter with DMA, perhaps I should begin by there.That also depends on your protocol and bit rates. For lower baud rates and protocols of non-constant message length (like NMEA 183), I see no distinct advantage in using DMA. In the first case, the load is rather small. And when receiving arbitrary messages, you need to parse the received data anyway, so you won't gain much, if at all, with DMA. Only for using multichannel ADC setups the DMA is mandatory. Each ADC has just one result register.