|
第一次用DMA2D,使用寄存器到存储器模式没问题,读取传输到SDRAM中的数据也是正确的,但使用内存到内存模式,sdram中的数据始终不对,跟踪发现DMA2D传输出错(中断寄存器值为1),请教大家这大概是什么原因呢,就这么几个寄存器,实在找不到原因了void lcdFillColor(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t *color)
{
uint32_t tm = 0;
__HAL_RCC_DMA2D_CLK_ENABLE(); //开启DMA2D时钟
DMA2D->CR &= ~(DMA2D_CR_START); //停止DMA2D
DMA2D->CR = (0 << 16) | (0x1 << 9); //M2M,传输完成中断
DMA2D->FGPFCCR = LTDC_PIXEL_FORMAT_RGB565; //RGB565
DMA2D->FGOR = 0; //源偏移
DMA2D->OOR = 800 - (x2 - x1 + 1); //目标偏移
DMA2D->FGMAR = (uint32_t)color; //源地址
DMA2D->OMAR = (__IO uint32_t)(0xC0000000 + 2 * (800 * y1 + x1)); //目标地址
DMA2D->NLR = ((x2 - x1 + 1) << 16) | (y2 - y1 + 1); //行数
DMA2D->CR |= DMA2D_CR_START; //开启DMA2D
while ((DMA2D->ISR & DMA2D_ISR_TCIF_Msk) == RESET) //等待传输完成中断
{
tm++;
if (tm > 0xfffff) //超时
{
printf("timeout , %d\r\n", DMA2D->ISR);
break;
}
}
DMA2D->IFCR |= DMA2D_ISR_TCIF_Msk; //清除传输完成中断
}
|
|