Hello support team,
I can read the ADC result with DMA, then I'd like to read the status of GPIO pins.
But when I replace the DMA source "&AdcaResultRegs.ADCRESULT0" with "&GpioDataReadRegs.GPADAT_R" or "&GpioDataRegs.GPADAT.all" in the code below, I cannot get correct status of pins.
Whole register is read as 0, although there are high and low pins.
Is there any thing should I take into account when reading GPIO pin status with DMA?
Read ADC result code => work correctly
EALLOW; // DMA_configAddresses DMA channel 1 set up for ADCA /* Set up SOURCE address. */ DmaRegs.CH2.SRC_BEG_ADDR_SHADOW = (u32)&AdcaResultRegs.ADCRESULT0; /* Point to beginning of source buffer */ DmaRegs.CH2.SRC_ADDR_SHADOW = (u32)&AdcaResultRegs.ADCRESULT0; /* Set up DESTINATION address. */ DmaRegs.CH2.DST_BEG_ADDR_SHADOW = (u32)u16AdcByDma; /* Point to beginning of destination buffer */ DmaRegs.CH2.DST_ADDR_SHADOW = (u32)u16AdcByDma; // Set up BURST registers. DmaRegs.CH2.BURST_SIZE.bit.BURSTSIZE = 0u; // Number of words(X-1) x-ferred in a burst. DmaRegs.CH2.SRC_BURST_STEP = 0u;// Increment source addr between each word x-ferred. DmaRegs.CH2.DST_BURST_STEP = 0u;// Increment dest addr between each word x-ferred. // Set up TRANSFER registers. DmaRegs.CH2.TRANSFER_SIZE = 99u; // Number of bursts per transfer, DMA interrupt will occur after completed transfer. DmaRegs.CH2.SRC_TRANSFER_STEP = 0u;// TRANSFER_STEP is ignored when WRAP occurs. DmaRegs.CH2.DST_TRANSFER_STEP = 1;// TRANSFER_STEP is ignored when WRAP occurs. /* disable wrapping */ DmaRegs.CH2.SRC_WRAP_SIZE = 0xFFFFu; DmaRegs.CH2.DST_WRAP_SIZE = 0xFFFFu; // Set up trigger selection in the CMA/CLA trigger source selection registers. These are considered part of system control. DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH2 = DMA_TRIGGER_ADCA1; // Set peripheral interrupt select bits to the channel number (legacy bits - hard coded to channel) DmaRegs.CH2.MODE.bit.PERINTSEL = 2u; // Write the configuration to the mode register. DmaRegs.CH2.MODE.bit.DATASIZE = 0u; /* DMA transfers 16 bits at a time. */ DmaRegs.CH2.MODE.bit.CONTINUOUS = 1u; DmaRegs.CH2.MODE.bit.ONESHOT = 0u; // Set the peripheral interrupt trigger enable bit. DmaRegs.CH2.MODE.bit.PERINTE = 1u; DmaRegs.CH2.MODE.bit.OVRINTE = 0u; /* the DMA channel interrupt will be generated at the end of the transfer */ DmaRegs.CH2.MODE.bit.CHINTMODE = 1u; PieVectTable.DMA_CH2_INT = &dmach2ISR; /* Map ISR functions */ DmaRegs.CH2.MODE.bit.CHINTE = 1u; /* enableInterrupt */ /* Write a one to the clear bit to clear the peripheral trigger flag. */ // Clear any spurious flags: Interrupt flags and sync error flags DmaRegs.CH2.CONTROL.bit.PERINTCLR = 1u; DmaRegs.CH2.CONTROL.bit.ERRCLR = 1; CPU_EnableIRQ(INT_DMA_CH2); /* Enable DMA 1 Interrupt */ DmaRegs.CH2.CONTROL.bit.RUN = 1u; EDIS;
Read pin status code => Read all 0
/* Set up SOURCE address. */ DmaRegs.CH2.SRC_BEG_ADDR_SHADOW = (u32)&GpioDataReadRegs.GPADAT_R; /* Point to beginning of source buffer */ DmaRegs.CH2.SRC_ADDR_SHADOW = (u32)&GpioDataReadRegs.GPADAT_R;
/* Set up SOURCE address. */ DmaRegs.CH2.SRC_BEG_ADDR_SHADOW = (u32)&GpioDataRegs.GPADAT.all; /* Point to beginning of source buffer */ DmaRegs.CH2.SRC_ADDR_SHADOW = (u32)&GpioDataRegs.GPADAT.all;
Regards,
Quy