Question
STM32F429I Discovery Peripheral to Memory doesn't work at all DMA
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] >> 8) & 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);
}
