I have been working on a project and have run into an issue with the DSK6713 EDMA and GPIO. I have inherited some working code and tried to adapt it to the project.
Here is what I'm attempting to accomplish:
- Take 2 interrupt signals (edge triggered low->high) into the GPIO pins 4 & 6 (Also EXTINT4 and EXTINT6).
- Perform GPIO Logic Mode function AND (delta mode) to create a GPINT0 event.
- Handle the GPINT0 event in the EDMA to trigger a channel transfer event.
- EDMA event to trigger data processing
So far this code has not worked and I have been going back and forth between 3-4 datasheets trying to sort out where the issue may be.
I'm wondering if the GPIO & EDMA are being configured correctly to perform as I would like.
EDMA_Config gEdmaConfigRcv = {
EDMA_FMKS(OPT, PRI, HIGH) | // Priority
EDMA_FMKS(OPT, ESIZE, 32BIT) | // Element size
EDMA_FMKS(OPT, 2DS, NO) | // 2 dimensional source?
EDMA_FMKS(OPT, SUM, OF(0)) | // Src update mode, fixed ADC address 0xB0000000
EDMA_FMKS(OPT, 2DD, NO) | // 2 dimensional dest
EDMA_FMKS(OPT, DUM, INC) | // Dest update mode
EDMA_FMKS(OPT, TCINT, YES) | // Cause EDMA interrupt?
EDMA_FMKS(OPT, TCC, OF(8)) | // Transfer complete code
EDMA_FMKS(OPT, LINK, YES) | // Enable link parameters? for pong, no link
EDMA_FMKS(OPT, FS, NO), // Use frame sync?
(Uint32) rxMEM_SRC, // Src address
EDMA_FMK (CNT, FRMCNT, NULL) | // Frame count
EDMA_FMK (CNT, ELECNT, BUFFSIZE), // Element count
(Uint32)&gBufferRcvPing, // Dest address
EDMA_FMKS(IDX, FRMIDX, DEFAULT) | // Frame index value
EDMA_FMKS(IDX, ELEIDX, DEFAULT), // Element index value
EDMA_FMK (RLD, ELERLD, NULL) | // Reload element
EDMA_FMK (RLD, LINK, NULL) // Reload link
};
void initEdma(void)
{
/* Configure receive channel */
//Map GPINT0 (8) event to EDMA channel (4)
hEdmaRcv = EDMA_open(EDMA_map(8,EDMA_CHA_EXTINT4), EDMA_OPEN_RESET); // get hEdmaRcv handle and reset channel
hEdmaReloadRcvPing = EDMA_allocTable(-1); // get hEdmaReloadRcvPing handle
hEdmaReloadRcvPong = EDMA_allocTable(-1); // get hEdmaReloadRcvPong handle
gEdmaConfigRcv.dst = EDMA_DST_OF(gBufferRcvPing);
EDMA_config(hEdmaRcv, &gEdmaConfigRcv); // configure the registers for hEdmaRcv
EDMA_config(hEdmaReloadRcvPing, &gEdmaConfigRcv); // and the reload for Ping
gEdmaConfigRcv.dst = EDMA_DST_OF(gBufferRcvPong); // change the structure to have a destination of Pong
EDMA_config(hEdmaReloadRcvPong, &gEdmaConfigRcv); // configure the reload for Pong
EDMA_link(hEdmaRcv,hEdmaReloadRcvPong); // link to Pong
EDMA_link(hEdmaReloadRcvPong,hEdmaReloadRcvPing); // link Pong to Ping
EDMA_link(hEdmaReloadRcvPing,hEdmaReloadRcvPong); // link Ping to Pong
/* Enable interrupts in the EDMA controller */
EDMA_intClear(8); // clear any possible spurious interrupts
EDMA_intEnable(8); // enable EDMA interrupts (CIER)
EDMA_enableChannel(hEdmaRcv); // enable EDMA channel
EDMA_setChannel(hEdmaRcv);
return;
}
GPIO_Config gpio_config ={
0x00000032, //GPGC - LOGICMODE, LOGICTRUE = 0(active high), ANDMODE,DELTAMODE
0x00000051, //GPEN - GPIO 0,4 enabled, 6 for 2 channel config 0x00000051
0x00000000, //GDIR - 0 = input, 1 = output
0x00000000, //GPVAL - since all input, just detects value, leave 0 for all.
0x00000050, //GPHM - 4, 6 for 2 channel config 0x00000050
0x00000000, //GPLM - Don't use high to low transitions
0x00000000 //GPPOL - Only applies to pass through mode (not this use)
};
void initIrq(void)
{
/* Enable EDMA interrupts to the CPU */
IRQ_nmiEnable();
IRQ_globalEnable();
IRQ_map(IRQ_EVT_EDMAINT, 8);
IRQ_reset(IRQ_EVT_EDMAINT); // Clear any pending EDMA interrupts
IRQ_enable(IRQ_EVT_EDMAINT); // Enable EDMA interrupt
return;
}
void edmaHwi( void )
{
EDMA_intClear(8);
//Direct to ping or pong buffer
if (pingOrPong==PING)
{
SWI_or(&processBufferSwi, PING);
pingOrPong = PONG;
}
else
{
SWI_or(&processBufferSwi, PONG);
pingOrPong = PING;
}
}
int main(void)
{
/*other code*/
gpio_handle = GPIO_open(GPIO_DEV0, GPIO_OPEN_RESET);
GPIO_config(gpio_handle, &gpio_config);
initEdma();
initIrq();
/*other code*/
return;
}
I am using a Spectrum Digital TMS320C6713 DSK.
I have added the pull down resistor to the HPI_EN pin to disable the HPI and enable the GPIO pins by switching the SW3 switch 4 to on.
Thank you.