Hi Mark,
Thank you for your prompt reply.
I'm using the MCU Xpresso IDE which is the current option offered by NXP. So I use the driver libraries that comes with that IDE.
I also tryed this, but same results:
GPIOA->PDDR |= 1<<2;
GPIOA->PSOR |= 1<<2;
What exactly "PORT_SetPinConfig()" function does? I can't find it in the driver library that I'm using.
How can I configure the MUX to GPIO in PTA2 at register level? which specific register must I configure?
Below an extract of the "GPIO_PinInit"
typedef enum _gpio_port_num
{
kGPIO_PORTA = 0U,
kGPIO_PORTB,
kGPIO_PORTC,
kGPIO_PORTD,
kGPIO_PORTE,
kGPIO_PORTF,
kGPIO_PORTG,
kGPIO_PORTH,
} gpio_port_num_t;
typedef struct _gpio_pin_config
{
gpio_pin_direction_t pinDirection; /*!< GPIO direction, input or output */
uint8_t outputLogic; /*!< Set a default output logic, which has no use in input */
} gpio_pin_config_t;
void GPIO_PinInit(gpio_port_num_t port, uint8_t pin, const gpio_pin_config_t *config)
{
assert(config);
uint8_t instance = (uint8_t)port / PORT_NUMBERS_EACH_GPIO;
uint8_t shift = (uint8_t)port % PORT_NUMBERS_EACH_GPIO;
GPIO_Type *base = s_gpioBases[instance];
if (config->pinDirection == kGPIO_DigitalInput)
{
base->PDDR &= ~(1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));
base->PIDR &= ~(1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));
}
else
{
GPIO_PinWrite(port, pin, config->outputLogic);
base->PDDR |= (1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));
base->PIDR |= (1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));
}
}
void GPIO_PinWrite(gpio_port_num_t port, uint8_t pin, uint8_t output)
{
uint8_t instance = (uint8_t)port / PORT_NUMBERS_EACH_GPIO;
uint8_t shift = (uint8_t)port % PORT_NUMBERS_EACH_GPIO;
GPIO_Type *base = s_gpioBases[instance];
if (output == 0U)
{
base->PCOR = 1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT));
}
else
{
base->PSOR = 1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT));
}
}
Thanks again.
Best regards.