STM32F4 parallel input using HAL and DMA [SOLVED]
I have a very basic 8-bit parallel line on pins PC0-PC7 with its clock on PB6. The MCU is a 411RE, I'm using STM32CubeIDE and HAL libraries.
I've read AN4666 but the examples provided are written using an obsolete library, not HAL. But I understood that I have to use a Timer in Input Capture mode to activate the DMA transfer. To do this, in CubeMX I configured TIM4 as follows:
- Slave Mode: Reset Mode
- Trigger Source: TI1FP1
- Internal Clock
- Channel1: Input Capture direct mode
Then in the DMA Settings tab I added one line:
- DMA Request: TIM4_CH1
- Stream: DMA1 Stream0
- Direction: Peripheral To Memory
- Priority: Low
- Mode: Normal
- Increment Address: Memory
- Use FIFO: yes
- Word to Byte
- Burst: Single
Does this configuration make any sense? My idea is to transfer the contents of register GPIOC->IDR (dimension: Word 32bit) to a uint8_t buffer (dimension Byte 8bit).
I also need an interrupt to count how many transfers were done or simply when the destination buffer is full. This is because I have to receive N 8bit frames before I can do anything with the data.
If the configuration is correct, I don't have any idea on how to use the HAL library to configure the source and destination registers and interrupts.
I have prepared a minimal setup with a button and the parallel lines connected to DIP switches.
Any help or hint is appreciated, it's a couple of days I am messing around trying to adapt stuff from examples written with the old library and from examples which use other DMA configurations, like moving data from ADC. But I the moment I did reach any kind of success.
Thanks
