MODM7AE70 GPIO configuration question

Discussion to talk about software related topics only.
Post Reply
Anguel
Posts: 30
Joined: Fri Aug 23, 2019 12:39 am

MODM7AE70 GPIO configuration question

Post by Anguel »

Hi,

I have to control external devices via GPIO pins on my MODM7AE70 and it is critical to not have any unexpected glitches.
Looking at the Netburner GPIO examples I see that pin configuration is done like this:

Code: Select all

// first initialize the pin as ouput:
P2[15].setFn( PinIO::PIN_FN_OUT);
// then set it HIGH
P2[15] = 1;
Now the problem with this approach is that the first line not only sets the pin to be an output but also activates it to be LOW, which is probably the default state.
So my question is how to prevent the pin from going LOW first when I want it to be HIGH as soon as I set it to output?
I tested to set the pin to HIGH first and then set it to output like this:

Code: Select all

// first set it HIGH
P2[15] = 1;
// then initialize the pin as output:
P2[15].setFn( PinIO::PIN_FN_OUT);
This seems to work at first glance but the problem is that I am not sure if this is the correct and safe way to do it.

Looking at the Microchip ASF code examples I see that they do everything in one single line and also allow to define additional pin parameters in a single step:

Code: Select all

void pio_set_output	(	Pio * 	p_pio,
		const uint32_t 	ul_mask,
		const uint32_t 	ul_default_level,
		const uint32_t 	ul_multidrive_enable,
		const uint32_t 	ul_pull_up_enable 
)
Example:

Code: Select all

pio_set_output(PIOA, PIO_PA23, LOW, DISABLE, ENABLE);
So what is the correct way to do it with the Netburner software? Any help and comments are welcome.

Thanks in advance,

Anguel
User avatar
dciliske
Posts: 623
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: MODM7AE70 GPIO configuration question

Post by dciliske »

Setting the pin prior to enabling the output is in fact the correct way. This is actually one of the reasons why for the MODM7AE70 we diverged the behavior of the pins class from the Coldfire platforms to require that you explicitly set the pin function to output (to allow presetting the output state without currently driving it).
Dan Ciliske
Project Engineer
Netburner, Inc
Post Reply