2007-06-26 08:30 PM
External DMA Request and EMI data transfer
2011-05-17 12:44 AM
2011-05-17 12:44 AM
Ok, so hopefully now my question is displayed in this forum.. :)
Did anyone utilized external DMA request (DMA_RQST0 or DMA_RQST1 pin) to read or write data on EMI interface using DMA channel? The problem is, that I found no information how to configure DMA to accept external DMA request in datasheets. Here is my piece of code, which I tried to configure DMA channel to accept external DMA request on pin DMA_RQST0 and send data from test buffer to EMI interface. In datasheet I found info, that the default input function of the pin P3.0 is DMA_RQST0, so after looking at GPIO pin schematic I think there is no need to change this GPIO pin configuration. Also note, that before this piece of code is executed, application is succesfully running and DMA block is enabled. The last note about the code is, that I do not use ST library functions, since these are useless when using LLI (linked list item) chained buffers. Instead of this I directly configure DMA registers based on LLI descriptor content, but the Macro values (DMA_TCIE,..) are the same as in ST library. ------------------------------------------------------------------------ //test buffer #define TESTSIZE 256 static u8 testbuf[TESTSIZE]; int i; for(i=0;i testbuf[i]=i; //stop dma channel DMA_Channel0->CCNF = 0; //set-up DMA channel 0 configuration register DMA_Channel0->CCNF = DMA_FlowCntrl_Perip1 | DMA_DES_External_Req0; //set-up the descriptor static LLI_InitTypeDef lli; lli.SrcAdd = (u32)testbuf; lli.DesAdd = 0x3C000000; lli.Pointer = (u32) &lli; lli.CCR = DMA_TCIE | DMA_CacheChannel | DMA_BufferChannel | DMA_ChannelSRCInc | DMA_DesWidth_Byte | DMA_SrcWidth_Byte | DMA_DesBst_1Data | DMA_SrcBst_1Data | (TESTSIZE>>1); //configure DMA registers from info in the first descriptor DMA_Channel0->SRC = lli.SrcAdd; DMA_Channel0->DES = lli.DesAdd; DMA_Channel0->LLI = lli.Pointer; DMA_Channel0->CC = lli.CCR; . . . //main loop while(1); ------------------------------------------------------------------------ So, after running this code nothing happens on any type of DMA request signal on DMA_RQST0 (risigng edge, falling edge, level ''0'', level ''1''). When I have tested direct EMI write, so it was ok, I can see data on EMI interface.. So please can you help me to understand how to activate DMA request properly? :o Thank you, Jan2011-05-17 12:44 AM
hi,
I'm working with external dma... the emi is configured as 16bit.... the code used to init the dma is the follow: volatile u32 DMA_Link[16] = { // SRC DEST NEXT LINK CCx REG ADC_BASE_ADRESS ,0x00000000, 0x00000000, CCxREG, ADC_BASE_ADRESS ,0x00000000, 0x00000000, CCxREG, ADC_BASE_ADRESS ,0x00000000, 0x00000000, CCxREG, ADC_BASE_ADRESS ,0x00000000, 0x00000000, CCxREG | 0x80000000 // trig irq }; void AD_DMA_Init() { DMA_InitTypeDef DMA_InitStruct; static TIM_InitTypeDef TIM_InitStructure; TIM_DeInit(TIM0); /* TIM0 Deinitialization */ TIM_ITConfig(TIM0, TIM_IT_OC1, DISABLE); TIM_StructInit(&TIM_InitStructure); TIM_InitStructure.TIM_Mode = TIM_PWM; TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB; TIM_InitStructure.TIM_Prescaler = 0x00; TIM_InitStructure.TIM_Pulse_Level_1 = TIM_LOW; TIM_InitStructure.TIM_Period_Level = TIM_HIGH; TIM_InitStructure.TIM_Pulse_Length_1 = TIMER_TICKS(AD_CONV_PULSE) ; // init a zero duty TIM_InitStructure.TIM_Full_Period = 0x0060; /* Initialize the Timer 0 */ TIM_Init(TIM0, &TIM_InitStructure); TIM_SetPulse(TIM0, TIM_OC2_Channel, TIMER_TICKS(AD_SAMPLING_PERIOD) ); TIM_CounterCmd(TIM0, TIM_START); // pointer to dest memory DMA_Link[1] = (u32)(&AD_buffer[0x0000]); DMA_Link[5] = (u32)(&AD_buffer[0x0800]); DMA_Link[9] = (u32)(&AD_buffer[0x1000]); DMA_Link[13] = (u32)(&AD_buffer[0x1800]); DMA_Link[2] = (u32)(&DMA_Link[4]); DMA_Link[6] = (u32)(&DMA_Link[8]); DMA_Link[10] = (u32)(&DMA_Link[12]); DMA_SyncConfig(DMA_External_Req0_Mask, DISABLE); DMA_StructInit(&DMA_InitStruct); // Write the first LLI DMA_InitStruct.DMA_Channel_LLstItm = DMA_Link[2]; DMA_InitStruct.DMA_Channel_SrcAdd = ADC_BASE_ADRESS; DMA_InitStruct.DMA_Channel_Src = DMA_SRC_External_Req0; DMA_InitStruct.DMA_Channel_DesAdd = (u32)AD_buffer; DMA_InitStruct.DMA_Channel_SrcWidth = DMA_SrcWidth_Word; DMA_InitStruct.DMA_Channel_DesWidth = DMA_DesWidth_Word; DMA_InitStruct.DMA_Channel_FlowCntrl= DMA_FlowCntrl2_DMA; DMA_InitStruct.DMA_Channel_TrsfSize = 0x0800; DMA_Init(DMA_Channel0,&DMA_InitStruct); // Configure the DMA channel0 DMA_ChannelSRCIncConfig(DMA_Channel0, DISABLE); DMA_ChannelDESIncConfig(DMA_Channel0, ENABLE); DMA_ITMaskConfig(DMA_Channel0, DMA_ITMask_ITC , ENABLE); VIC_Config(DMA_ITLine, VIC_IRQ, 3); VIC_ITCmd(DMA_ITLine, ENABLE); } void AD_DMA_Read() { DMA_Channel0->CCNF &= ~DMA_ChannelEnable; /* Set the source address */ DMA_Channel0->SRC = ADC_BASE_ADRESS; /* Set the destination address */ DMA_Channel0->DES = (u32)AD_buffer; /* Set the linked list Items address */ DMA_Channel0->LLI = DMA_Link[2]; DMA_Channel0->CC = DMA_Link[3]; DMA_Channel0->CCNF |= DMA_ChannelEnable; }