Hello,
I am currently trying to get a photo array running on an IMX8DX. (I am using SDK_2_9_0_MIMX8UX5xxxFZ)
For that i need a PWM (currently build via TPM) and falling edge detection.
My plan would be to use a GPIO as INPUT, in mode: falling edge detection (as example: H14 -> LSIO.GPIO4.IO04) connected to the PWM PIN, but I don't understand how to correctly setup the Interrupt of the GPIO.
Can someone help me with an example?
My current (not working) solution:
@main.c
#define PWM_INTERRUPT_GPIO LSIO__GPIO4
#define PWM_INTERRUPT_GPIO_PIN 4U
#define PWM_INTERRUPT_GPIO_IRQ LSIO_GPIO_INT0_IRQn
#define PWM_INTERRUPT_GPIO_IRQ_HANDLER_FUNC PWM_INTERRUPT_HANDLER
void PWM_INTERRUPT_HANDLER(void)
{
GPIO_ClearPinsInterruptFlags(PWM_INTERRUPT_GPIO, 1U); //mask?
PRINTF("INSIDE GPIO INTERRUPT\n\r");
SDK_ISR_EXIT_BARRIER; //PREDEFINED: Fix for interrupt too slow for clock
}
int main(void)
{
sc_ipc_t ipc;
ipc = BOARD_InitRpc();
BOARD_InitPins(ipc);
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
BOARD_InitMemory();
gpio_pin_config_t pwm_int_config = {kGPIO_DigitalInput, 0, kGPIO_IntFallingEdge};
sc_pm_set_resource_power_mode(ipc, SC_R_IRQSTR_M4_0, SC_PM_PW_MODE_ON);
EnableIRQ(PWM_INTERRUPT_GPIO_IRQ); //How to connect GPIO to corr IRQ?
GPIO_PinInit(PWM_INTERRUPT_GPIO, PWM_INTERRUPT_GPIO_PIN, &pwm_int_config);
GPIO_PortEnableInterrupts(PWM_INTERRUPT_GPIO, 1U << PWM_INTERRUPT_GPIO_PIN); //How to correctly enable?
@pin_mux.h
/* PWM_INTERRUPT_GPIO at GPIO133 corresponding with H14 ALT4*/
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_GPIO LSIO_GPIO4
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_GPIO_PIN 4U
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_PIN_NAME USB_SS3_TC1
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_PIN_FUNCTION_ID SC_P_USB_SS3_TC1
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_LABEL "PWM_INTERRUPT_SODIMM_133"
#define BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_NAME "PWM_INTERRUPT_SODIMM_133"
@pin_mux.c
err = sc_pad_set_all(ipc, BOARD_INITPINS_PWM_INTERRUPT_GPIO_133_PIN_FUNCTION_ID, 4U, SC_PAD_CONFIG_NORMAL, SC_PAD_ISO_OFF, 0x0 ,SC_PAD_WAKEUP_OFF);
if (SC_ERR_NONE != err)
{
assert(false);
}
Solved! Go to Solution.
Thank you very much for your help.
I got it working like that and the interrupt works now as intended.
I still ave a few other questions on PWMs/TPMs and multi Channel ADC but I will open new topics since it doesn't belong here.
Best Regards,
Cillex
Hi @Cillex ,
I hope you are doing well.
As the issue seems resolved, can I mark this case as close?
Thanks & Regards,
Sanket Parekh
Yes, thank you very much