I2C Master operation inside GPIO interrupt handler

cancel
Showing results for 
Search instead for 
Did you mean: 

I2C Master operation inside GPIO interrupt handler

Jump to solution
189 Views
jayeshj
Contributor III

Hi @Kan_Li,

I am using PN7462 in my system. On the I2CM bus of PN7462 and one of them is the BMA accelerometer. Now in the use case, it is important to clear BMA to interrupt as soon as possible for catching the next interrupt and make the interrupt line ideal.

For achieving the above goal we took an approach where whenever a GPIO interrupt occurs we read the status of the BMA interrupt register(1Byte register) within the interrupt handler. But in doing so controller restarts every time. Below is a snippet of the interrupt handler routine for our development.

 

void GPIO_12_IRQHandler( void )
{
	PH_REG_SET_BIT_WO( PCR_INT_CLR_STATUS_REG , GPIO12_PAD_HIGH_INT_CLR_STATUS );
	phHal_Nvic_ClearPendingInterrupt( 1U << ( PHHAL_NVIC_GPIO_12_Isr ) );

	uint32_t ulRegValue = 0;
	char usI2C_Address = 0x19;
	uint32_t ulValue = 0x1C;
	tHAL_I2CM_Write( usI2C_Address, (uint8_t *)&ulValue, 1 );
	tHAL_I2CM_Read( usI2C_Address, (uint8_t *)&ulRegValue, 1 );
}

 

Is there any reason why PN7462 is restarting in this situation?

0 Kudos
1 Solution
7 Views
jayeshj
Contributor III

@Fabian_R 

I did see simmilar behaviour with NXP EVK and function available in SDK. It looks like it casauing due to interrupt collision. We have moved the I2C operation to thread for now as a solution.

View solution in original post

0 Kudos
2 Replies
8 Views
jayeshj
Contributor III

@Fabian_R 

I did see simmilar behaviour with NXP EVK and function available in SDK. It looks like it casauing due to interrupt collision. We have moved the I2C operation to thread for now as a solution.

View solution in original post

0 Kudos
126 Views
Fabian_R
NXP TechSupport
NXP TechSupport

Hello Jayesh,
We appreciate your preference for our products.

Could you please test this by using our functions available in the SDK, this will help us clarify if misbehaviour is happening while performing this sequence. This test might also be helpful for you by debugging the function and following the executions.

I hope this helps in the creation of your application!

Best Regards,
Fabian