Quantcast
Channel:
Viewing all articles
Browse latest Browse all 59170

Forum Post: RE: multi ADC Transfer with DMAC to PingPongBuffer

$
0
0
You did not mention sampling rate or how much time you have etc. Since the RX is fairly efficient in handling pointers, MACs and has a barrel shifter, the way I solved this with the DMAC is: a) put the ADC channels in order so the result registers are in order for DMAC block transfer b) use the BLOCK mode, it transfers all my results (I was doing 8 channels) c) ping buffer interrupt, reset count, start processing ping data d) pong buffer interrupt, reset count, reset DMAC destination pointer to ping buffer and start processing data So your data would end up U1,V1,W1, Z1, U2, V2, W2, Z2,.... I guess you have to decide where you need the performance most, in the data capture or the averaging code. I was doing 8 channels 32 blocks before processing data. If using RX FIT DMAC driver , my config data sample is below. COMMENTS: 1. this was done on RX231 device 2. remember, fixed rate sampling and averaging creates boxcar filter. Hope this helps.    /* Configure the DMA */    DMA_cfg.transfer_mode = DMACA_TRANSFER_MODE_BLOCK;                              //Block mode is used    DMA_cfg.repeat_block_side = DMACA_REPEAT_BLOCK_SOURCE;                          //The source is repeated    DMA_cfg.data_size = DMACA_DATA_SIZE_WORD;                                       //Data size is set to 16bits    DMA_cfg.act_source = IR_S12AD_S12ADI0;                                          //Trigger on ADC Interrupt    DMA_cfg.request_source = DMACA_TRANSFER_REQUEST_PERIPHERAL;                     //Trigger from peripheral module    DMA_cfg.dtie_request = DMACA_TRANSFER_END_INTERRUPT_ENABLE;                     //Trigger interrupt after destination is full    DMA_cfg.esie_request = DMACA_TRANSFER_ESCAPE_END_INTERRUPT_DISABLE;             //Do not trigger escape interrupts    DMA_cfg.rptie_request = DMACA_REPEAT_SIZE_END_INTERRUPT_DISABLE;                //Do not trigger repeat size end interrupts    DMA_cfg.sarie_request = DMACA_SRC_ADDR_EXT_REP_AREA_OVER_INTERRUPT_DISABLE;     //Do not trigger src overflow interrupts    DMA_cfg.darie_request = DMACA_DES_ADDR_EXT_REP_AREA_OVER_INTERRUPT_ENABLE;      //Do not trigger dest overflow interrupts    DMA_cfg.src_addr_mode = DMACA_SRC_ADDR_INCR;                                    //Source address increments through size    DMA_cfg.src_addr_repeat_area = DMACA_SRC_ADDR_EXT_REP_AREA_NONE;                //No extended area for src    DMA_cfg.des_addr_mode = DMACA_DES_ADDR_INCR;                                    //Destination address is incremented by block size    DMA_cfg.des_addr_repeat_area = DMACA_DES_ADDR_EXT_REP_AREA_NONE;                //No extended area for dest    DMA_cfg.offset_value = 0;                                                       //Offset set to block size    DMA_cfg.interrupt_sel = DMACA_CLEAR_INTERRUPT_FLAG_BEGINNING_TRANSFER;          //clear the interrupt flag on call to DMA    DMA_cfg.p_src_addr = (void *)src;                                               //Our source start = &S12AD.ADDR0    DMA_cfg.p_des_addr = (void *)&adc_ping_pong;                                    //Our destination start = &adc_ping_pong    DMA_cfg.transfer_count = 32;                                                    //Transfer 32 blocks before interrupt triggers    DMA_cfg.block_size = 8;                                                         //Read 8 values before source reset    ret = R_DMACA_Create(DMACA_CH0, &DMA_cfg);    while (DMACA_SUCCESS != ret)       {           nop();  //Your error handler here.       }

Viewing all articles
Browse latest Browse all 59170

Trending Articles