Hello. I am using MM9Z1_638D1 for a project.
How should I correctly configure a GPIO (PTB3) as an output and drive it?
Current implementation:
B_GPIO_CTL = (B_GPIO_CTL_PE3M_MASK | B_GPIO_CTL_DIR3M_MASK); // enable mask
B_GPIO_CTL |= (B_GPIO_CTL_PE3_MASK | B_GPIO_CTL_DIR3_MASK); // enable
B_GPIO_PUC_PUE3 = 1; // pull up enable
B_GPIO_OUT3 = 1; // turning on
B_GPIO_OUT3 = 0; // turning off
Is my understanding correct?
Am I missing something?
I don't see any voltage on that pin.
Hi Mihir,
the MM9Z1_638 device has registers with masked bits, which allow to set or clear individual bits without the need for a read-modify-write process.
The masked bits correlate to the same "bit name", e.g. B_GPIO_CTL_DIR3(M)_MASK.
For example see the following code examples:
B_GPIO_CTL = (B_GPIO_CTL_DIR3M_MASK | B_GPIO_CTL_DIR3_MASK); // set PTB3 as OUTPUT
B_GPIO_CTL = (B_GPIO_CTL_DIR3M_MASK | 0 ); // set PTB3 as INPUT
Corrected implementation:
B_GPIO_CTL = (B_GPIO_CTL_PE3M_MASK | B_GPIO_CTL_PE3_MASK ); // enable PTB3 GPIO function
B_GPIO_CTL = (B_GPIO_CTL_DIR3M_MASK| B_GPIO_CTL_DIR3_MASK); // set PTB3 as OUTPUT
B_GPIO_PUC_PUE3 = 1; // pull up enable
B_GPIO_OUT3 = 1; // turning on
B_GPIO_OUT3 = 0; // turning off
Rgds
W.
Is this the right way to drive the pin?
B_GPIO_OUT3 = 1; // turning on
B_GPIO_OUT3 = 0; // turning off
The datasheet talks about PTBX3 as output buffer control.
Yes, correct!