TI F28069M LaunchPad - XINT
5 views (last 30 days)
Show older comments
I'm working w/ TI F28069M LaunchPad w/ Embedded Coder Support Package/Simulink.
I'm testing external interrupt using push sw.
The goal is to turn on the led10 (GPIO39) when push sw is pressed and turn off the led when push sw is released.
-Push sw is pulled up and conected to GPIO4. (i.e. Push : GPIO4 Low)
-LED10 (GPIO39) is also pulled up (i.e. GPIO39 Low : LED On)
I configured the GPIO4 as XINT1 and falling edge in the HW setting configuration.
Result)
Led is turned-off --> When the push sw is pressed --> the led is turned-on very short time
I guess the XINT1 is executed during very short time.
I want to know how to set hardware interrupt exit condition, for example,
- I want to turn on the led for 5 seconds.
- I want to turn on the led when push sw is pressed and turn off the led when push sw is released.
0 Comments
Answers (1)
Sivapriya Srinivasan
on 27 Sep 2023
Edited: Sivapriya Srinivasan
on 9 Oct 2023
Hello,
I understand that you want to set a specific exit condiion for your hardware interupt ,you can follow the following steps:
1.Configure the GPIO4 as XINT1 and set it to trigger on the falling edge, as you mentioned. This will ensure that the interrupt is triggered when the push switch is pressed.
2.In the interrupt service routine (ISR) for XINT1, you can implement the logic to turn on LED10 (GPIO39) and set a timer to turn it off after a specific duration.
Start a timer for 5 seconds when the push switch is pressed. You can use a timer peripheral available on your microcontroller (e.g., Timer1).
Inside the ISR, set a flag to indicate that the push switch is pressed.
In the main program loop, check the flag status. If the flag is set, check if the timer has expired. If the timer has expired, turn off LED10.
3.To turn off the LED when the push switch is released, you can use another interrupt, such as XINT2, triggered on the rising edge of GPIO4.
Configure GPIO4 as XINT2 and set it to trigger on the rising edge.
In the XINT2 ISR, clear the flag indicating that the push switch is pressed and turn off LED10.
For a general outline,the general implementation may vary depending on the specific hardware
Make sure to refer the documentation and examples provided by TI 28069M launchpad and Embedded Coder Support Pcakge/Simlink to adapt the code :Embedded Coder Support Package for Texas Instruments C2000 Processors - File Exchange - MATLAB Central (mathworks.com)
Hope this helps!
// Global variables
volatile bool switchPressed = false; // Flag to track switch state
// Interrupt Service Routine for XINT1
interrupt void xint1_isr(void)
{
// Clear the interrupt flag
// ...
// Check the state of the switch
if (GPIO4 == 0) // Assuming GPIO4 is the input pin connected to the switch
{
switchPressed = true;
// Turn on the LED
// ...
}
else
{
switchPressed = false;
// Turn off the LED
// ...
}
}
// Main function
int main(void)
{
// Initialize GPIO and other peripherals
// ...
// Configure XINT1 interrupt
// ...
// Enable global interrupts
// ...
while (1)
{
if (switchPressed)
{
// Handle LED behavior based on the switch state
// ...
}
else
{
// Handle LED behavior when the switch is not pressed
// ...
}
}
}
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!