Hi,
I am trying to interface the USB STK through Samtec connector to a Keypad. I am using revision C with 40 pins expansion connector. I have few doubts in using GPIO.
I have also attached my code snipped at the end of the questions. PLEASE REPLY AS SOON AS POSSIBLE.
I have following issues:
1) Although C5505 DSP manual says about pull-up/pull-down reisistor, GPIO User's Guide speaks ONLY about pull-down resistor. Download “GPIO_Test1.zip” from http://code.google.com/p/c5505-ezdsp/downloads/list also talks about pull-down resistor. What's the actual configuration?
2) Now, isn't it the case that, if I disable pull-down resistor, the corresponding pin should go high (3V3 in this case)? But when I do that, I find 0V or close to 0V on the pins configured as INPUT. Could you please explain this?
3) Even after clearing the flag in interrupt flag resistor, I am not able to process more than one interrupt. Could you please tell me the mistake if any?
I have ensured following things:
1) Pins are properly selected using multiplexing.
2) Pins are properly configured.
3) I have referred to this post http://e2e.ti.com/support/dsp/tms320c5000_power-efficient_dsps/f/110/p/11101/43192.aspx#43192.
//****************************************************************************************
CSL_Status status;
CSL_GpioPinConfig config;
// Pin muxing for GPIO GP[11:0]
CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP0MODE, MODE2); //6 GP[5:0] signals are routed to the
//6 external signals of the serial port 0
CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP1MODE, MODE2); //6 GP[11:6] signals are routed to the
//6 external signals of the serial port 0
CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_A20_MODE, MODE1); //GP[26]
CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_A19_MODE, MODE1); //GP[25]
CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_A18_MODE, MODE1); //GP[24]
CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_A17_MODE, MODE1); //GP[23]
CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_A16_MODE, MODE1); //GP[22]
CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_A15_MODE, MODE1); //GP[21]
CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_PPMODE, MODE2); //GP[31:27], GP[20:18] are routed to
//21 external signals of the parallel port
PDINHIBR1 = 1;
PDINHIBR2 = 1;
PDINHIBR3 = 1; //Disable = open
printf("Pull Down resistors %x %x %x\n", PDINHIBR1,PDINHIBR2,PDINHIBR3);
/* Disable CPU interrupt */
IRQ_globalDisable();
/* Clear any pending interrupts */
IRQ_clearAll();
/* Disable all the interrupts */
IRQ_disableAll();
/* Initialize Interrupt Vector table */
IRQ_setVecs((Uint32)(&VECSTART));
/* Open GPIO module */
hGpio = GPIO_open(&GpioObj,&status);
if((NULL == hGpio) || (CSL_SOK != status))
{
printf("GPIO_open failed\n");
return(CSL_TEST_FAILED);
}
else
{
printf("GPIO_open Successful\n");
}
/* Reset the GPIO module */
GPIO_reset(hGpio);
/* GPIO_config API to make PIN12 as output pin */
//Purple
config.pinNum = CSL_GPIO_PIN12;
config.direction = CSL_GPIO_DIR_INPUT; //OUTPUT;
config.trigger = CSL_GPIO_TRIG_FALLING_EDGE;
status = GPIO_configBit(hGpio,&config);
if(CSL_SOK != status)
{
printf("test failed - GPIO_configBit\n");
return(CSL_TEST_FAILED);
}
else
{
printf("GPIO PIN12 is configured as Input Pin\n");
}
/* GPIO_config API to make PIN15 as output pin */
//Blue
config.pinNum = CSL_GPIO_PIN15;
config.direction = CSL_GPIO_DIR_INPUT; //OUTPUT;
config.trigger = CSL_GPIO_TRIG_FALLING_EDGE;
status = GPIO_configBit(hGpio,&config);
if(CSL_SOK != status)
{
printf("test failed - GPIO_configBit\n");
return(CSL_TEST_FAILED);
}
else
{
printf("GPIO PIN15 is configured as Input Pin\n");
}
/* GPIO_config API to make PIN16 as output pin */
//Green
config.pinNum = CSL_GPIO_PIN16;
config.direction = CSL_GPIO_DIR_INPUT; //OUTPUT;
config.trigger = CSL_GPIO_TRIG_FALLING_EDGE;
status = GPIO_configBit(hGpio,&config);
if(CSL_SOK != status)
{
printf("test failed - GPIO_configBit\n");
return(CSL_TEST_FAILED);
}
else
{
printf("GPIO PIN16 is configured as Input Pin\n");
}
/* GPIO_config API to make PIN11 as output pin */
//Yellow
/*
config.pinNum = CSL_GPIO_PIN11;
config.direction = CSL_GPIO_DIR_INPUT; //OUTPUT;
config.trigger = CSL_GPIO_TRIG_FALLING_EDGE;
status = GPIO_configBit(hGpio,&config);
if(CSL_SOK != status)
{
printf("test failed - GPIO_configBit\n");
return(CSL_TEST_FAILED);
}
else
{
printf("GPIO PIN11 is configured as Input Pin\n");
}
*/
/** test GPIO_config API to make PIN5 as i/p */
config.pinNum = CSL_GPIO_PIN5;
config.direction = CSL_GPIO_DIR_OUTPUT;
config.trigger = CSL_GPIO_TRIG_FALLING_EDGE;
status = GPIO_configBit(hGpio,&config);
if(CSL_SOK != status)
{
printf("test failed - GPIO_configBit\n");
return(CSL_TEST_FAILED);
}
else
{
printf("GPIO PIN5 is configured as Output Pin\n");
}
/** test GPIO_config API to make PIN27 as i/p */
config.pinNum = CSL_GPIO_PIN27;
config.direction = CSL_GPIO_DIR_OUTPUT;
config.trigger = CSL_GPIO_TRIG_FALLING_EDGE;
status = GPIO_configBit(hGpio,&config);
if(CSL_SOK != status)
{
printf("test failed - GPIO_configBit\n");
return(CSL_TEST_FAILED);
}
else
{
printf("GPIO PIN27 is configured as Output Pin\n");
}
/** test GPIO_config API to make PIN6 as i/p */
config.pinNum = CSL_GPIO_PIN6;
config.direction = CSL_GPIO_DIR_OUTPUT;
config.trigger = CSL_GPIO_TRIG_FALLING_EDGE;
status = GPIO_configBit(hGpio,&config);
if(CSL_SOK != status)
{
printf("test failed - GPIO_configBit\n");
return(CSL_TEST_FAILED);
}
else
{
printf("GPIO PIN6 is configured as Output Pin\n");
}
/** test GPIO_config API to make PIN8 as i/p */
config.pinNum = CSL_GPIO_PIN8;
config.direction = CSL_GPIO_DIR_OUTPUT;
config.trigger = CSL_GPIO_TRIG_FALLING_EDGE;
status = GPIO_configBit(hGpio,&config);
if(CSL_SOK != status)
{
printf("test failed - GPIO_configBit\n");
return(CSL_TEST_FAILED);
}
else
{
printf("GPIO PIN8 is configured as Output Pin\n");
}
// Enable GPIO interrupts
status = GPIO_enableInt(hGpio,CSL_GPIO_PIN12);
if(CSL_SOK != status)
{
printf("test failed- GPIO_enableInt 12\n");
return(CSL_TEST_FAILED);
}
else
{
printf("GPIO_enableInt 12");
}
// Enable GPIO interrupts
status = GPIO_enableInt(hGpio,CSL_GPIO_PIN15);
if(CSL_SOK != status)
{
printf("test failed- GPIO_enableInt 15\n");
return(CSL_TEST_FAILED);
}
// Enable GPIO interrupts
status = GPIO_enableInt(hGpio,CSL_GPIO_PIN16);
if(CSL_SOK != status)
{
printf("test failed- GPIO_enableInt 16\n");
return(CSL_TEST_FAILED);
}
// Enable GPIO interrupts
/*
status = GPIO_enableInt(hGpio,CSL_GPIO_PIN11);
if(CSL_SOK != status)
{
printf("test failed- GPIO_enableInt 11\n");
return(CSL_TEST_FAILED);
}
*/
/*
// Enable GPIO interrupts
status = GPIO_enableInt(hGpio,CSL_GPIO_PIN5);
if(CSL_SOK != status)
{
printf("test failed- GPIO_enableInt 5\n");
return(CSL_TEST_FAILED);
}
// Enable GPIO interrupts
status = GPIO_enableInt(hGpio,CSL_GPIO_PIN27);
if(CSL_SOK != status)
{
printf("test failed- GPIO_enableInt 27\n");
return(CSL_TEST_FAILED);
}
// Enable GPIO interrupts
status = GPIO_enableInt(hGpio,CSL_GPIO_PIN6);
if(CSL_SOK != status)
{
printf("test failed- GPIO_enableInt 6\n");
return(CSL_TEST_FAILED);
}
// Enable GPIO interrupts
status = GPIO_enableInt(hGpio,CSL_GPIO_PIN8);
if(CSL_SOK != status)
{
printf("test failed- GPIO_enableInt 8\n");
return(CSL_TEST_FAILED);
}
*/
/* Clear any pending Interrupt */
IRQ_clear(GPIO_EVENT);
IRQ_plug(GPIO_EVENT,&gpioISR);
/* Enabling Interrupt */
IRQ_enable(GPIO_EVENT);
IRQ_globalEnable();
//Keypad interfacing specific code
}
interrupt void gpioISR(void)
{
CSL_Status status;
i = 0;
printf("Interrupt routine called %d\n",i);
printf("Flag Reg 1 -> %x Flag Reg 2 -> %x\n", *((Uint16 *)(0x1C10)), *((Uint16 *)(0x1C11)));
if((1 == GPIO_statusBit(hGpio,CSL_GPIO_PIN12,&status)))
{
/* Clear GPIO Interrupt Flag Register */
printf("pin12 status bit set\n");
GPIO_clearInt(hGpio,CSL_GPIO_PIN12);
}
//IRQ_disable(GPIO_EVENT);
/* Read data on pin 11 */
//status = GPIO_read(hGpio, CSL_GPIO_PIN11, &readVal);
*((volatile ioport Uint16 *)(0x1C10)) |= 0xffff;
*((volatile ioport Uint16 *)(0x1C11)) |= 0xffff;
printf("Flag Reg 1 %x Flag Reg 2 %x\n", *((Uint16 *)(0x1C10)), *((Uint16 *)(0x1C11)));
i++;
}
//****************************************************************************************