2024-05-22 05:09 AM - edited 2024-05-22 05:11 AM
hello everyone, I have a board.STM32F429I DISCO1, the question arose:
is it possible to read the parallel , a 16-bit from port(from the input pins) using some external interrupt (for example, using the rising edge of an external-nterrupt), to the DMA , and how to implement this in cubeMX and stm32cubeide .
Thank you in advance .
2024-05-22 06:12 AM
Yes, you'd need something on DMA2 (supporting Memory-to-Memory, M2M), so a TIM on APB2, with a TIMx_CHx in Input-Capture mode that can also be mapped as a DMA trigger.
2024-05-23 08:31 AM
thanks for the response.
I want to read, say, two bytes of parallel data from port A{15:0}, into the DMA buffer, every time a rising edge of some signal comes to the microcontroller from the outside.
How exactly can this be implemented ?
2024-05-23 08:58 AM
I'm not the coder on this project. Think of me as the unpaid guy on street giving directions, not a taxi driver to your destination.
I've previously demonstrated and posted how to trigger/capture GPIO via DMA on the F2/F4 but that was in SPL days not HAL.
The GPIO->IDR is 16-bit wide so DMA configured in HALF-WORD mode should suffice into a pattern buffer. The trigger comes via TIM plumbing, described in the Reference Manual, the pins for the TIM in the Data Sheet.
You need to use a TIM on APB2 because only DMA2 allows for memory-to-memory transfers, &GPIOx->IDR is within the broader 4GB address space, on the AHB of the F4, and requires a multi-stage operation rather than piping memory to/from a peripheral internal to APB2 in a direct wired fashion.
2024-05-23 09:03 AM
The newer H7 designs have a parallel bus method PSSI ? Older designs with synchronous capture, perhaps DCMI but width there is only14-bit. Other than that a latch on the F(S)MC and an EXTI
For classic DREQ implementations, TIM + DMA, Input Capture, One Edge/Both
2024-05-29 04:21 AM
Can I in board.STM32F429I DISCO1 , Configure DMA to transfer data from the GPIO port to a memory buffer ?
because I dont see that , in CubeMX may support direct GPIO to memory transfer for this use case ?
but can I manually handle this , ? for example
#define BUFFER_SIZE 1
uint16_t dma_buffer[BUFFER_SIZE];
void MX_DMA_Init(void) {
....................................................
DMA_HandleTypeDef hdma;
hdma.Instance = DMA1_Stream0;
hdma.Init.Channel = DMA_CHANNEL_0;
hdma.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma.Init.PeriphInc = DMA_PINC_DISABLE;
hdma.Init.MemInc = DMA_MINC_ENABLE;
hdma.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
..................................................................
}
.................................................................................
HAL_DMA_Start(&hdma, (uint32_t)&GPIOA->IDR, (uint32_t)dma_buffer, BUFFER_SIZE);
.........................................................................................................
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
if (GPIO_Pin == GPIO_PIN_0) { // Assuming PB0 is the EXTI line
Start_DMA(); }
}