This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2541:使用 CC2541 P0_6时的密钥扫描问题

Guru**** 2577385 points
Other Parts Discussed in Thread: CC2541

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/565558/cc2541-key-scan-issue-for-using-cc2541-p0_6

器件型号:CC2541

使用 CC2541的 P0_6作为密钥扫描输入。 上升沿中断。  

如果按下按钮3次或3次以上、中断将始终被触发。

如果按1次按钮、则表示正常

如果交换 P0_5 (或 P0_7)的密钥扫描电路和 P0_6的密钥扫描电路、P0_6仍然错误、P0_5 (或 P0_7)正常。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    是否可以附加 hal_key.c?
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    P0INP&=~0xff;
    P1INP&&=~0x3c;
    P2INP|=0x20;
    P0SEL&=~0xff;
    P0DIR&=~0xff;

    P1SEL&=~0x3F;
    P1DIR|=0x3f;
    P1|=0x3f;

    P0IEN |=0xff;
    PICTL |=0x00;
    IEN1 |= 0x20;
    P0IEN =~0xff;
    IEN1 &=~0x20;

    //按键:

    空 HalKeyPoll (空)


    uint8 notify=0;

    P1DIR|=0x3f;
    P1|=0x3f;

    if ((key_Pressed1 == 0x00)&&(((P0&0xff)!=0x00))//按键


    Key_Presed1 = 1;
    keys=Check_Key();

    notify = 1;

    否则、如果((key_Pressed1 ==1)&&(((P0&0xff)=0x00))//密钥释放

    Key_Presed1 = 0;
    键[0]= 0;
    键[1]=0;
    notify = 1;
    *keys=0;


    否则、如果((key_Pressed1 ==1)&&(((P0&0xff)!=0x00))//始终按键

    ………………………………μ A 。


    //按键扫描:
    uint8 *检查键(空)

    uint8行,col,tmp1,tmp2,n=0;
    tmp2=0x01;

    for (row = 0;row <6;row++)

    p1=tmp2;
    if (((P0&0xff)!=0x0)

    tmp1 = 0x01;
    for (col = 0;col <8;col++)

    if (((P0& tmp1)!= 0)

    key_val[n]= key_Map[row * 8 + col];//获取密钥值

    N++;
    如果(n=2)

    返回 key_val;


    tmp1 <<= 1;



    tmp2<<=1;

    返回 key_val;



    //IO 中断:

    HAL_ISR_Function (halKeyPort0Isr、P0INT_vector)

    HAL_ENTER_ISR ();


    if (P0IFG &0xff)


    void osal_start_timerEx (hal_taskID、HAL_key_event、30);//延迟30ms

    P0IFG &=~0xff; //清除中断标志

    P0IF = 0;
    CLEAR_SLEEP_MODE();
    HAL_EXIT_ISR();

    返回;
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    "P0IEN&=~0xff;"和"IEN1 &=~0x20;"将禁用所有 P0引脚的中断、这会使您的 P0.6中断无效。