主题中讨论的其他器件: HALCOGEN
工具/软件:
你(们)好
我希望在端口 B[3]的上升沿和下降沿发生中断。 下面是我的代码。 请帮助我检查是否正确。
gioREG->INTDET =(Uint32)((Uint32) 1U << 0U)/*位 0 */
|(Uint32)((Uint32) 1U << 1U)/*位 1 */
|(Uint32)((Uint32) 1U << 2U)/*位 2 */
|(Uint32)((Uint32) 1U << 3U)/*位 3 */
|(Uint32)((Uint32) 0U << 4U)/*位 4 */
|(Uint32)((Uint32) 0U << 5U)/*位 5 */
|(Uint32)((Uint32) 0U << 6U)/*位 6 */
|(Uint32)((Uint32) 0U << 7U)/*位 7 */
|(Uint32)((Uint32) 1U << 8U)/*位 8 */
|(Uint32)((Uint32) 1U << 9U)/*位 9 */
|(Uint32)((Uint32) 1U << 10U)/*位 10 */
|(Uint32)((Uint32) 1U << 11U)/*位 11 *///端口 B[3]已启用中断
|(Uint32)((Uint32) 0U << 12U)/*位 12 */
|(Uint32)((Uint32) 0U << 13U)/*位 13 */
|(Uint32)((Uint32) 0U << 14U)/*位 14 */
|(Uint32)((Uint32) 0U << 15U);//*位 15 */
/**-中断极性*/
gioREG->POL =(Uint32)((Uint32) 1U << 0U)/*位 0 */
|(Uint32)((Uint32) 1U << 1U)/*位 1 */
|(Uint32)((Uint32) 1U << 2U)/*位 2 */
|(Uint32)((Uint32) 1U << 3U)/*位 3 */
|(Uint32)((Uint32) 0U << 4U)/*位 4 */
|(Uint32)((Uint32) 0U << 5U)/*位 5 */
|(Uint32)((Uint32) 1U << 6U)/*位 6 */
|(Uint32)((Uint32) 0U << 7U)/*位 7 */
|(Uint32)((Uint32) 1U << 8U)/*位 8 */
|(Uint32)((Uint32) 1U << 9U)/*位 9 */
|(Uint32)((Uint32) 1U << 10U)/*位 10 */
|(Uint32)((Uint32) 1U << 11U)/*位 11 */端口 B[3]设置 1 表示双边沿中断
|(Uint32)((Uint32) 0U << 12U)/*位 12 */
|(Uint32)((Uint32) 0U << 13U)/*位 13 */
|(Uint32)((Uint32) 0U << 14U)/*位 14 */
|(Uint32)((Uint32) 1U << 15U);/*位 15 */
/**-中断级别*/
gioREG->LVLSET =(Uint32)((Uint32) 1U << 0U)/*位 0 */
|(Uint32)((Uint32) 1U << 1U)/*位 1 */
|(Uint32)((Uint32) 1U << 2U)/*位 2 */
|(Uint32)((Uint32) 1U << 3U)/*位 3 */
|(Uint32)((Uint32) 0U << 4U)/*位 4 */
|(Uint32)((Uint32) 0U << 5U)/*位 5 */
|(Uint32)((Uint32) 1U << 6U)/*位 6 */
|(Uint32)((Uint32) 0U << 7U)/*位 7 */
|(Uint32)((Uint32) 1U << 8U)/*位 8 */
|(Uint32)((Uint32) 1U << 9U)/*位 9 */
|(Uint32)((Uint32) 1U << 10U)/*位 10 */
|(Uint32)((Uint32) 1U << 11U)/*位 11 *///端口 B[3]
|(Uint32)((Uint32) 0U << 12U)/*位 12 */
|(Uint32)((Uint32) 0U << 13U)/*位 13 */
|(Uint32)((Uint32) 0U << 14U)/*位 14 */
|(Uint32)((Uint32) 1U << 15U);/*位 15 */
/**-启用中断*/
gioREG->ENASET =(UINT32)(UINT32) 1U << 0U)/*位 0 */
|(Uint32)((Uint32) 1U << 1U)/*位 1 */
|(Uint32)((Uint32) 1U << 2U)/*位 2 */
|(Uint32)((Uint32) 1U << 3U)/*位 3 */
|(Uint32)((Uint32) 0U << 4U)/*位 4 */
|(Uint32)((Uint32) 0U << 5U)/*位 5 */
|(Uint32)((Uint32) 0U << 6U)/*位 6 */
|(Uint32)((Uint32) 0U << 7U)/*位 7 */
|(Uint32)((Uint32) 1U << 8U)/*位 8 */
|(Uint32)((Uint32) 1U << 9U)/*位 9 */
|(Uint32)((Uint32) 1U << 10U)/*位 10 */
|(Uint32)((Uint32) 1U << 11U)/*位 11 *///端口 B[3]
|(Uint32)((Uint32) 0U << 12U)/*位 12 */
|(Uint32)((Uint32) 0U << 13U)/*位 13 */
|(Uint32)((Uint32) 0U << 14U)/*位 14 */
|(Uint32)((Uint32) 0U << 15U);//*位 15 */
Ahove in HL_Gio.c
以下是应用代码:
void HWP_vMstOverSpdIntHandle (void)
{
uint8_t u8Cnt=0U;
hwp_bMstOverSpdInt=true;
IIF ((gioREG->POL & BIT11)!= 0U)//如果上升沿、设置定时器端口 B[3]
{
hwp_u32MstOverSpdIntTimer=u32GetSysTimer_ms ();//有效高电平输入
HWP_u8MstOverSpdIntPol=1U;//上升沿中断
HWP_u16MstOverSpdState=1U;
}
否则 f ((gioREG->POL & BIT11)== 0u)//如果下降沿、则计数脉冲
{
HWP_u8MstOverSpdIntPol=2U;//下降沿中断
hwp_u32MstOverSpdIntCurrentTime=u32GetSysTimer_ms();
HWP_u16MstOvrSpdIntCntr++;//有效脉冲
}
}
void gioNotification(gioPORT_t *端口、Uint32 位)
{
if ((gioPORTB == port)&&(位== 3U))//硬件主器件超速端口
{
hwp_vMstOverSpdIntHandle();
}
}
我问的原因是、如果我使用 gioREG->POL 检测下降沿、则不会进入下降沿例程。 因此、我必须使用端口级别读数进行检查。 检测中断引脚的两个边沿的理想方法是什么
请发表评论。 谢谢你





