Reputation: 1
I am working on a custom board with two IMX7ULP. The thing I'm trying to do seems quite simple, the A7 from one IMX7ULP send a signal to the M4 of the other IMX7ULP, just an electrical signal, one of the pin of the A7 as output, one of the pin of the M4 as input (PTA16), no special communication protocol. We manage to set the pin of the A7 as an output (even checked with the multimeter) and we do what seems correct to set the pin as an input but nothing is read and it keeps returning me a value of 0.
The code I made looks like this
#define GPIO_HEARTBEAT_READ 16U
gpio_pin_config_t digitalInput = { //set as input
kGPIO_DigitalInput,
};
/* Init board hardware. */
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
CLOCK_EnableClock(kCLOCK_Rgpio2p0);
/* Init input GPIO. */
GPIO_PinInit(GPIOA, GPIO_HEARTBEAT_READ, &digitalInput);
int value = GPIO_PinRead(GPIOA, GPIO_HEARTBEAT_READ);
PRINTF("Value of HEARTBEAT_READ : %d\n", value);
PRINTF("Value of register of heartbeat : %x\n", READ_reg());
and value is set as 0 while the register read 0x10100 which is what I am expecting for a pin set as input.
I also checked the IOMUXC mode to make sure it is correctly set as GPIO :
void BOARD_InitPins(void) {
IOMUXC_SetPinMux(IOMUXC_PTA16_PTA16, 0U);
}
I even tried forcing it in pull-down to create a difference in potential at the pin but nothing changed. I'm currently running out of ideas, is there something I'm missing ? Is it more a hardware problem than software (if it's the case, I apologize and I'll be looking somewhere else)
Thank you in advance
Edit : someone asked for a code where they blinked the LED, which was given by default and I changed it to try taking an input instead :
#define LED_GPIO_PIN 20U
int main(void)
{
gpio_pin_config_t digitalOutput = { //allows for setting the pin as an output
kGPIO_DigitalOutput,
0,
};
/* Init board hardware. */
BOARD_InitPins();
BOARD_BootClockRUN();
//BOARD_InitDebugConsole();
CLOCK_EnableClock(kCLOCK_Rgpio2p0);
/* Init output LED GPIO. */
GPIO_PinInit(GPIOA, LED_GPIO_PIN, &digitalOutput);
GPIO_PortSet(GPIOA, 1u << LED_GPIO_PIN);
while(1) {
delay(10000);
GPIO_PortToggle(GPIOA, 1u << LED_GPIO_PIN);
}
}
We were also able to set the M4 pin as output and the A7 pin as input and to receive a signal on the A7
Last edit : I don't why but I managed to get the pin info using interrupts and NVIC IRQ Handler. Still no value read with GPIO_PinRead though. Thank you for the comments, it helped.
Upvotes: 0
Views: 142
Reputation: 59
Try declaring the int as volatile.
volatile int value = GPIO_PinRead(GPIOA, GPIO_HEARTBEAT_READ);
It could be that the compiler is optimizing that section instead of actually reading the value.
Upvotes: 0