Hi!
I'm trying to handle interrupts generated on rising edges of GPIO.
Could you make some suggestions what I'm missing in the code below?
The gpio_task is called, but then no interrupt is generated while toggling the GPIO0 and GPIO1 pins.
CSL_GpioRegsOvly hGpio = (CSL_GpioRegsOvly)CSL_GPIO_0_REGS;
#define GPIO_CFG_BASE (0x02B00000)#define GPIO_REG_BINTEN (0x8)#define GPIO_REG_DIR (0x10)#define GPIO_REG_OUT_DATA (0x14)#define GPIO_REG_SET_DATA (0x18)#define GPIO_REG_CLR_DATA (0x1C)#define GPIO_REG_IN_DATA (0x20)#define GPIO_REG_SET_RIS_TRIG (0x24)#define GPIO_REG_CLR_RIS_TRIG (0x28)#define GPIO_REG_SET_FAL_TRIG (0x2C)#define GPIO_REG_CLR_FAL_TRIG (0x30)
void gpio_task(void){
LOG_printf(&trace,"gpio_task called");
// Set GPIO 0 and 1 as outputs // Note: Normally you would want these as inputs, but in this case we // are configuring them as outputs to eliminate the need for external // loopbacks, etc. hGpio->DIR &= (~3); // set DIR0 and DIR1 to set them as outputs
// Enable rising edge interrupt on GPIO 0 and 1 hGpio->SET_RIS_TRIG = 0x3;
// Enable BINTEN.EN0 (it gates all interrupts pertaining to bank0 pins) hGpio->BINTEN |= 1;
while(1) { // Generate rising edge on GPIO 0 and 1 hGpio->CLR_DATA = 3; hGpio->SET_DATA = 3;
TSK_sleep(100); }}
void gpio_0(){ LOG_printf(&trace,"Executing gpio_0 ISR.");}
void gpio_1(){ LOG_printf(&trace,"Executing gpio_1 ISR.");}
void main(void) {
//set GPIO_0 pin as an input //*(unsigned int*)(GPIO_CFG_BASE+GPIO_REG_DIR) |= 0x1; //set GPIO_0 pin as an output *(unsigned int*)(GPIO_CFG_BASE+GPIO_REG_DIR) &= 0xFFFFFFFE;
//set rising edge to trigger GPIO_0 interrupt *(unsigned int*)(GPIO_CFG_BASE+GPIO_REG_SET_RIS_TRIG) |= 0x1;
//clear falling edge of GPIO_0 *(unsigned int*)(GPIO_CFG_BASE+GPIO_REG_SET_FAL_TRIG) &= 0xFFFFFFFE;
//enable GPIO interrupts *(unsigned int*)(GPIO_CFG_BASE+GPIO_REG_BINTEN) |= 0x1;
//Start BIOS BIOS_start();
/* fall into DSP/BIOS idle loop */ return;
}
the TCF file looks like this:
utils.loadPlatform("ti.platforms.evm6472");
/* The following DSP/BIOS Features are enabled. */bios.enableRealTimeAnalysis(prog);bios.enableRtdx(prog);bios.enableTskManager(prog);
bios.LOG.create("trace");bios.LOG.instance("trace").bufLen = 2048;bios.TSK.instance("TSK_idle").order = 1;
bios.TSK.create("GPIO");bios.TSK.instance("GPIO").order = 3;bios.TSK.instance("GPIO").fxn = prog.extern("gpio_task");bios.TSK.instance("GPIO").priority = 3;
bios.HWI.instance("HWI_INT4").interruptSelectNumber = 64;bios.HWI.instance("HWI_INT4").fxn = prog.extern("gpio_0");bios.HWI.instance("HWI_INT4").useDispatcher = 1;bios.HWI.instance("HWI_INT4").interruptMask = "all";
bios.HWI.instance("HWI_INT5").interruptSelectNumber = 65;bios.HWI.instance("HWI_INT5").fxn = prog.extern("gpio_1");bios.HWI.instance("HWI_INT5").useDispatcher = 1;bios.HWI.instance("HWI_INT5").interruptMask = "all";
// !GRAPHICAL_CONFIG_TOOL_SCRIPT_INSERT_POINT!
prog.gen();
Thanks in advance!
Regards,
./z
Zoltan,
I strongly recommend you start with examples from the CSL library for the C6472 and/or from the MCSDK 1.x which also includes the CSL. I seem to recall there was an example for GPIOs that does an internal loopback and generates interrupts.
Get one of those TI-supplied examples working, with interrupts, with GPIOs, and then try to move to your own specific application requirements.
Regards,RandyP
Search for answers, Ask a question, click Verify when complete, Help others, Learn more.