Other Parts Discussed in Thread: C2000WARE
Tool/software:
Hi guys,
I am learning to use C2000 MCUs ont he F2800137 launchpad. I am doing an interrupt exercise similar to the example given in C2000Ware "gpio_ex3_interrupt". I want to use a digital output to trigger an interrupt which should toggle an LED in its ISR.
The issue I am facing is that the interrupt succesfully triggers the ISR, however the LED does not get toggled. The only way to make the LED toggle is to put a breakpoint on the toggle command, and re run the program. This way the LED toggles, but without a breakpoint it does not. I know that the ISR gets executed even when I do not have a breakpoint active in it, since I have a variable which increments each time the ISR executes and I can see it incrementing but the LED not toggling. Anybody have any suggestions?
This is how I approached programming:
1. I took an "empty_driverlib_project" template from C2000ware examples.
2. I configured the LED gpios and a thrid GPIO which i want to use as the interrupt trigger source.
void MyGPIOInit(void) { // Configure LED1 GPIO as output with default value 1. GPIO_setPinConfig(DEVICE_GPIO_CFG_LED1); // Configure LED pin GPIO20 as GPIO. GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD); // Configure output as push-pull. GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1); // Preload output pin state 1. GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT); // Configure pin GPIO20 as output. // Configure LED2 GPIO as output with default value 1. GPIO_setPinConfig(DEVICE_GPIO_CFG_LED2); GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD); GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1); GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT); // Configure GPIO as dOut with interrupt XINT1 during transition from 0 to 1. GPIO_setPinConfig(GPIO_0_GPIO0); // Configure GPIO 0 as GPIO. GPIO_setPadConfig(0, GPIO_PIN_TYPE_STD); // Push-pull output config. GPIO_writePin(0, 0); // Default low output. GPIO_setDirectionMode(0, GPIO_DIR_MODE_OUT); // Configuration as output. GPIO_setInterruptType(GPIO_INT_XINT1, GPIO_INT_TYPE_RISING_EDGE); // Set int trigger rising edge. GPIO_setInterruptPin(0, GPIO_INT_XINT1); // Connect int XINT1 to GPIO 0. GPIO_enableInterrupt(GPIO_INT_XINT1); // Enable XINT1 in GPIO. }
3. I enabled the XINT1 interrupt and configured the ISR address to MyGPIO_ISR function.
Interrupt_enable(INT_XINT1); // Enable XINT1 interrupt. Interrupt_register(INT_XINT1, &MyGPIO_ISR); //Link XINT1 int to ISR MyGPIO_ISR.
4. In the ISR I toggle the LED, increment a global variable and clear the ACK bit.
__interrupt void MyGPIO_ISR(void) { GPIO_togglePin(22); NoOfInts++; Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1); // Clear ACK bit of group 1. }
What am I doing wrong? Your help is greatly appreciated. I have attached a .zip of the whole project.
Regards,
Samo