cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429I Discovery Peripheral to Memory doesn't work at all DMA

Ahmed Tolba
Associate II

Hello,

I'm trying to use interrupt + dma to capture port D data input, and the interrupt occurs but DMA is not starting to work at all.

Here is my code:

 

 

void HAL_DMA_TransferComplete(DMA_HandleTypeDef *hdma) {

if (hdma->Instance == DMA1_Stream0) {

uint8_t A1;

uint8_t CS1;

uint8_t CS2;

uint8_t data_byte = 0;

for (int i = 0; i < 8; i++) {

data_byte |= ((buffer[0] >> i) & 0x01) << i;

}

A1 = (buffer[0] >> 😎 & 0x01;

CS1 = (buffer[0] >> 9) & 0x01;

CS2 = (buffer[0] >> 10) & 0x01;

if ((!CS1) && (!A1)) {

LCD1_write_cmd(data_byte);

}

if ((!CS1) && (A1)) {

LCD1_write_dat(data_byte);

}

if ((!CS2) && (!A1)) {

LCD2_write_cmd(data_byte);

}

if ((!CS2) && (A1)) {

LCD2_write_dat(data_byte);

}



}

}

// External interrupt callback function

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {



if (GPIO_Pin == GPIO_PIN_0) { // PA0 IOWR



HAL_DMA_Start_IT(&hdma_adc1 , (uint32_t)&GPIOD->IDR, (uint32_t)&buffer, 256);



}

static void MX_DMA_Init(void) {

/* DMA controller clock enable */

__HAL_RCC_DMA1_CLK_ENABLE();



/* DMA interrupt init */

HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 0, 0);

HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn);



/* DMA initialization code */

hdma_adc1.Instance = DMA1_Stream0;

hdma_adc1.Init.Channel = DMA_CHANNEL_0;

hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;

hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;

hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;

hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;

hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;

hdma_adc1.Init.Mode = DMA_NORMAL;

hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;

hdma_adc1.Init.FIFOMode = DMA_FIFOMODE_DISABLE;

if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)

{

Error_Handler();

}

}

void DMA1_Stream0_IRQHandler(void) {

HAL_DMA_IRQHandler(&hdma_adc1);

}

 

22 REPLIES 22

Can you please share some pseudo code or an approach ? I didn't get it that much

is it possible to trigger on external interrupt IOWR, and use DMA to transfer port data ? data bus actually?


@Ahmed Tolba wrote:

Can you please share some pseudo code or an approach ? I didn't get it that much

is it possible to trigger on external interrupt IOWR, and use DMA to transfer port data ? data bus actually?


"... pseudo code or an approach": already covered in my previous reply - did you actually read it and spend some time thinking about it?  Maybe consider an FSM to capture the IOWR's and generate the writes to your other LCD?

"... interrupt and DMA": maybe, maybe not.  I believe my suggestion is simpler and would actually work.  You seem to be really hung up on using interrupts, timers, and DMA.  Good luck.

I already read it, but I could not understand it the approach, for example how do I poll on IOWR ?

on which event ? I need to capture all the data bus on falling edge IOWR, but how I keep polling it?