Hi,
I'm trying to use 'I2C MASTER HAL' with 'phhalI2CM_Transmit()' and 'phhalI2CM_Receive()' functions. I can use these functions in 'phExCcid_SystemTask' without any problem. But I can't use(can't send & receive data) them in "phExCcid_UsbCcid_Process".
I think the cause of the problem is about interrupt priorities. I tried to change I2C and HIF ınterrupt priorities as are initialized in "phFlasBoot.c" file.
/* interrupts at lowest levels */
phHal_Nvic_SetPendSVPrio(PH_HAL_INTRPT_PRIO_LOW);
phHal_Nvic_SetSysTick(PH_HAL_INTRPT_PRIO_LOW);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_BMA, PH_HAL_INTRPT_PRIO_LOW);
/* interrupts at medium prio */
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_TIMER, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_EECTRL, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_SPI, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_I2C, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_Common_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_01_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_02_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_03_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_04_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_05_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_06_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_07_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_08_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_09_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_10_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_11_Isr, PH_HAL_INTRPT_PRIO_MED);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_GPIO_12_Isr, PH_HAL_INTRPT_PRIO_MED);
/* interrupts at high prio */
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_CLIF, PH_HAL_INTRPT_PRIO_HIGH);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_HIF, PH_HAL_INTRPT_PRIO_HIGH);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_CTIF, PH_HAL_INTRPT_PRIO_HIGH);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_PMU, PH_HAL_INTRPT_PRIO_HIGH);
phHal_Nvic_SetInterruptPrio(PHHAL_NVIC_PCR, PH_HAL_INTRPT_PRIO_HIGH);
/* interrupts at real time prio */
phHal_Nvic_SetSvCPrio(PH_HAL_INTRPT_PRIO_REALTIME);
It didn't solve anything. What can I try to fix the problem?
Solved! Go to Solution.
Hi @EE_Ark
Please refer to the application architecture of the phExCcid example.
PN7462AU CCID reader application has 4 modules: USB ISR, system task, CL task, CT task.
phhalI2CM_Transmit()' and 'phhalI2CM_Receive() are blocking calls, they wait for the i2c transaction to complete. They can work in task context. as you mentioned, they can work in 'phExCcid_SystemTask' without any problem. But not good to work in an ISR. we can not call a blocking call in an ISR.
USB ISR is responsible for sending and receiving the CCID class commands through the bulk out, bulk in and interrupt endpoints.
I would suggest you perform the I2C transmit/receive operations in a task. or you can trigger an event in USB ISR, and wait the event in a task, then perform i2c sending/receiving in this task
Regards
Daniel
IF I use 'SET_HIF_USB_LOW_PRIORITY' it looks like it can communicate a few bytes but after that I receive a hard page fault.
Hi @EE_Ark
Please refer to the application architecture of the phExCcid example.
PN7462AU CCID reader application has 4 modules: USB ISR, system task, CL task, CT task.
phhalI2CM_Transmit()' and 'phhalI2CM_Receive() are blocking calls, they wait for the i2c transaction to complete. They can work in task context. as you mentioned, they can work in 'phExCcid_SystemTask' without any problem. But not good to work in an ISR. we can not call a blocking call in an ISR.
USB ISR is responsible for sending and receiving the CCID class commands through the bulk out, bulk in and interrupt endpoints.
I would suggest you perform the I2C transmit/receive operations in a task. or you can trigger an event in USB ISR, and wait the event in a task, then perform i2c sending/receiving in this task
Regards
Daniel