2019-08-16 22:31发布
jokeym 发表于 2017-7-17 10:51 贴码、不知道你怎么配的
jokeym 发表于 2017-7-17 17:01 没清中断标志位吧
最多设置5个标签!
void MYDMA_Config(DMA_Channel_TypeDef* DMA_CHx,u32 cpar,u32 cmar,u16 cndtr)
{
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); //ê1ÄüDMA′«êä
DMA_DeInit(DMA_CHx); //½«DMAμÄí¨μà1¼Ä′æÆ÷ÖØéèÎaè±ê¡Öμ
DMA1_MEM_LEN=cndtr;
DMA_InitStructure.DMA_PeripheralBaseAddr = cpar; //DMAíaéè»ùμØÖ·
DMA_InitStructure.DMA_MemoryBaseAddr = cmar; //DMAÄú′æ»ùμØÖ·
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; //êy¾Y′«êä·½Ïò£¬′óíaéè¶áè¡·¢Ëíμ½Äú′æ
DMA_InitStructure.DMA_BufferSize = cndtr; //DMAí¨μàμÄDMA»o′æμÄ′óD¡
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //íaéèμØÖ·¼Ä′æÆ÷2»±ä
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //Äú′æμØÖ·¼Ä′æÆ÷μYÔö
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; //êy¾Y¿í¶èÎa8λ
DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_Word; //êy¾Y¿í¶èÎa8λ
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; //1¤×÷ÔúÕy3£Ä£ê½
DMA_InitStructure.DMA_Priority = DMA_Priority_Medium; //DMAí¨μà xóμóDÖDóÅÏ輶
DMA_InitStructure.DMA_M2M = DMA_M2M_Enable; //DMAí¨μàxûóDéèÖÃÎaÄú′æμ½Äú′æ′«êä
DMA_Init(DMA_CHx, &DMA_InitStructure); //¸
DMA_ITConfig(DMA1_Channel4,DMA_IT_TC,ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel4_IRQn; //ê1Äü°′¼üËùÔúμÄía2¿ÖD¶Ïí¨μà
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //ÇàÕ¼óÅÏ輶0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //×óóÅÏ輶0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //ê1Äüía2¿ÖD¶Ïí¨μà
NVIC_Init(&NVIC_InitStructure); //¸ù¾YNVIC_InitStructÖDÖ¸¶¨μÄ2Îêy3õê¼»ˉíaéèNVIC¼Ä′æÆ÷
}
//¿aÆôò»′ÎDMA′«êä
void DMA1_Channel4_IRQHandler(void)
{
if(DMA_GetITStatus(DMA1_IT_TC2))
{
HREF_Cnt++;
if(HREF_Cnt!=59)
{
MYDMA_Enable(DMA1_Channel4);
}
DMA_ClearITPendingBit(DMA1_IT_GL4); //
LED1=!LED1;
}
}
void MYDMA_Enable(DMA_Channel_TypeDef*DMA_CHx)
{
DMA_Cmd(DMA_CHx, DISABLE ); //1رÕTIM4 êäèë2¶»ñ2 DMA1 ËùÖ¸ê¾μÄí¨μà
DMA_SetCurrDataCounter(DMA_CHx,DMA1_MEM_LEN);//DMAí¨μàμÄDMA»o′æμÄ′óD¡
DMA_Cmd(DMA_CHx, ENABLE); //ê1ÄüTIM4 êäèë2¶»ñ2 ËùÖ¸ê¾μÄí¨μà
}
MYDMA_Config(DMA1_Channel4,(u32)&GPIOC->IDR,(u32)OV7620_BUF[HREF_Cnt],1);
程序的整体思路。main函数-->dma初始化,定时器4通道2的输入捕获初始化,使能捕获触发dma请求,·外部中断初始化检测帧信号-->中断函数里开启dma使能-->.
dma的初始化中cmar为定义的数组,cpar为GPIOC->IDR,传输的方向cp to cm。
不知道这样对不对,主要是想实现将GPIOC->IDR上的数据通过dma传输到数组中。
一周热门 更多>