Not applicable
Aug 27, 2016
07:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 27, 2016
07:42 AM
Hi all,
Trying to get a XMC2Go and a pushbutton to work together to control an LED, am a bit lost though. Anyone have any examples they can point me to ?
Trying to get a XMC2Go and a pushbutton to work together to control an LED, am a bit lost though. Anyone have any examples they can point me to ?
- Tags:
- IFX
1 Reply
Aug 29, 2016
07:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 29, 2016
07:26 AM
So, there is a plenty of ways to perform the LED control using pushbutton, and this is only one solution. I´ve used the approach with XMC Libraries while it´s more user-friendly than direct register access approach and you don´t need to know who to use DAVE APPs.
I don´t know how you´re going to connect the pushbutton to the XMC2Go pin (while the board itself doesn´t provide pushbutton), so maybe your if-statement is going to be different. I´ve tested the example on the board that has a pushbutton and the pushbotton is connected to the pin as following:
#include
#define PUSHBUTTON ???? // define the port and the pin where you´ve connected pushbutton
#define LED1 P1_1
int main(void)
{
XMC_GPIO_SetMode(PUSHBUTTON, XMC_GPIO_MODE_INPUT_TRISTATE);
XMC_GPIO_SetMode(LED1, XMC_GPIO_MODE_OUTPUT_PUSH_PULL);
while(1U)
{
if(!XMC_GPIO_GetInput(PUSHBUTTON))
{
XMC_GPIO_SetOutputHigh(LED1);
}
else
{
XMC_GPIO_SetOutputLow(LED1);
}
}
}
I don´t know how you´re going to connect the pushbutton to the XMC2Go pin (while the board itself doesn´t provide pushbutton), so maybe your if-statement is going to be different. I´ve tested the example on the board that has a pushbutton and the pushbotton is connected to the pin as following: