Not applicable
Mar 13, 2016
06:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 13, 2016
06:19 AM
Why is it that if i use this.....the pin does not work....i.e. not output
XMC_GPIO_SetMode( P2_10, XMC_GPIO_MODE_OUTPUT_PUSH_PULL );
but.... if i use this ...... the pin does work.
pin_config.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL;
XMC_GPIO_Init( P2_10, &pin_config );
???
what is the correct procedure to setup pins and does it differ from different pins types ?
XMC_GPIO_SetMode( P2_10, XMC_GPIO_MODE_OUTPUT_PUSH_PULL );
but.... if i use this ...... the pin does work.
pin_config.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL;
XMC_GPIO_Init( P2_10, &pin_config );
???
what is the correct procedure to setup pins and does it differ from different pins types ?
2 Replies
Mar 13, 2016
08:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 13, 2016
08:09 PM
Hello,
Port 2 contains analog pin functionality and by default, the digital pin functionality is disabled.
Therefore, to enable Port 2 pins, the digital pin functionally needs to be especially enabled.
This step is automatically included in the XMC_GPIO_Init() function, which explains why you see the difference.
For the first method, you will need to add for PORT2 the following:
For non-analog pins, the two methods would have worked.
In general, I will recommend to use the pin init function.
Regards,
Min Wei
Port 2 contains analog pin functionality and by default, the digital pin functionality is disabled.
Therefore, to enable Port 2 pins, the digital pin functionally needs to be especially enabled.
This step is automatically included in the XMC_GPIO_Init() function, which explains why you see the difference.
For the first method, you will need to add for PORT2 the following:
XMC_GPIO_EnableDigitalInput(P2_10);
XMC_GPIO_SetMode( P2_10, XMC_GPIO_MODE_OUTPUT_PUSH_PULL );
For non-analog pins, the two methods would have worked.
In general, I will recommend to use the pin init function.
Regards,
Min Wei
Not applicable
Mar 14, 2016
02:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 14, 2016
02:32 AM
chismo wrote:
Hello,
Port 2 contains analog pin functionality and by default, the digital pin functionality is disabled.
Therefore, to enable Port 2 pins, the digital pin functionally needs to be especially enabled.
This step is automatically included in the XMC_GPIO_Init() function, which explains why you see the difference.
For the first method, you will need to add for PORT2 the following:
XMC_GPIO_EnableDigitalInput(P2_10);
XMC_GPIO_SetMode( P2_10, XMC_GPIO_MODE_OUTPUT_PUSH_PULL );
For non-analog pins, the two methods would have worked.
In general, I will recommend to use the pin init function.
Regards,
Min Wei
This does explain it, but it also shows a issue in the GPIO lib......
You should only have one method to setup a pin, the user should be abstracted away from the issue of if ports have different requirments