I2C Master operation inside GPIO interrupt handler

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

I2C Master operation inside GPIO interrupt handler

跳至解决方案
2,448 次查看
jayesh_joshi
Contributor IV

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?

标记 (4)
0 项奖励
回复
1 解答
2,266 次查看
jayesh_joshi
Contributor IV

@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.

在原帖中查看解决方案

0 项奖励
回复
2 回复数
2,267 次查看
jayesh_joshi
Contributor IV

@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.

0 项奖励
回复
2,385 次查看
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