金牌会员
- 积分
- 1010
- 威望
- 573
- 贡献
- 265
- 兑换币
- 281
- 注册时间
- 2012-4-28
- 在线时间
- 86 小时
- 毕业学校
- hit
|
本帖最后由 petime 于 2012-5-13 07:05 编辑
这个是我的dma初始化
void dma_init()
{
asm("nop");
volatile uint8 *tempptr1;
SIM_SCGC6 |= SIM_SCGC6_DMAMUX_MASK;//打开SMA多路复用时钟
SIM_SCGC7|=SIM_SCGC7_DMA_MASK; //打开DMA模块时钟
DMAMUX_CHCFG5|=DMAMUX_CHCFG_SOURCE(51);
DMAMUX_CHCFG5 |= DMAMUX_CHCFG_ENBL_MASK;//DMA channel is enabled
tempptr1 = &Image[0][Line_max-1];
DMA_SADDR(5) =(uint32)&GPIOB_PDIR;//设置源地址GPIO口,PORTB
DMA_DADDR(5)=(uint32_t)tempptr1;//0X400FF0CC;
DMA_NBYTES_MLNO(5) = DMA_NBYTES_MLNO_NBYTES(1);//每次读取一字节
DMA_NBYTES_MLOFFNO(5)=1;//Number of bytes to be transferred in each service request of the channel.
DMA_NBYTES_MLOFFYES(5)=1;//Number of bytes to be transferred in each service request of the channe
DMA_ATTR(5) = DMA_ATTR_SSIZE(0) | DMA_ATTR_DSIZE(0); //源数据宽度8bit,目的数据宽度8bit
DMA_SOFF(5) = 0;//每次传送源地址不变
DMA_DOFF(5)= -1;//每次写目的地址减1
DMA_SLAST(5) =0 ;//2*4次之后回到初始地//主循环结束后源地址0回写tcd
DMA_TCD5_BITER_ELINKNO=DMA_BITER_ELINKNO_BITER(Line_max);
DMA_TCD5_CITER_ELINKNO=DMA_CITER_ELINKNO_CITER(Line_max);
DMA_DLAST_SGA(5) = 0; //每次传输完成后向后推进一个byte
DMA_ERQ&=~DMA_ERQ_ERQ5_MASK ;//The DMA request signal for the corresponding channel is enabled
}
void portc_isr(void)
{
if(PORTC_PCR8&PORT_PCR_ISF_MASK) //herf
{
Row_count ++;
PORTC_PCR8|=PORT_PCR_ISF_MASK;
if ((Row_count>=10) && (Row_count==Gather_Row[Gather_Row_count]) && (Row_count<=240)&&Gather_Row_count<Row_max)
{
// tempptr = tempptr;
DMA_SADDR(5) =(uint32)&GPIOB_PDIR;
DMA_DADDR(5)=(uint32_t)&Image[m][Line_max-1];//0X400FF0CC; //0X400FF0C8; //ADDRESS OF PTD_PTOR
DMA_CDNE=DMA_CDNE_CDNE(5); //Clears the corresponding bit in TCDn_CSR[DONE]
DMA_ERQ|= DMA_ERQ_ERQ5_MASK ;
m++;
Gather_Row_count++;
}
}
if(PORTC_PCR10&PORT_PCR_ISF_MASK) // sync
{
Gather_Row_end=1;
m=0;
Row_count = 0;
Gather_Row_count=0;
Get_speed_cunt=0;
PORTC_PCR10|=PORT_PCR_ISF_MASK;
}
现象 : dma只传输一次
以前好使的了,这几天就突然不好使了,把摄像头直接连在单片机上,依然这样,排出了硬件原因
|
|