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 Interrupts

Other Parts Discussed in Thread: CC2541

Hi,

I was using CC2541

I used Port 1 to process the 2 digital interrupts from 2 different button press., everything works fine.

But when i tried configuring two buttons for the same pin using the Voltage differentiation concept, i connected the buttons to one of pins in Port 0, such that by defualt the pins are configured as digital and on the first interrupt, it moves to the Analog to measure the voltage to understand which button was really pressed. And once when the logic is processed, the pins are configured back to digital to accept the interrupts on further button press.

It seems to get fail sometimes, because of switching the configuration forth & back., any suggestion on this..

Regards

Suresh

  • Hi Suresh,

    I am not sure why you try to change them to analog mode, is it to measure the level with the ADC? What do you mean by "voltage differentiation concept"? Changing them to analog mode will disable the input buffer, so you cannot read out the level from a register.

    To check which pins generated an interrupt, you can read the P1IFG register. To check which buttons are currently pressed afterwards you can read the P1 register directly.

    Regards,
    Svend

  • Hi Svend,

    Thanks for your reply..

    Yes its to measure the level with ADC.,  so for each button press, a different voltage level would be generated. Say for instance if the button 1 is pressed, it generates around 300 to 340 mv, and if another button is pressed, it generates a different voltage level. Thus reading the ADC Level helps me to understand which button was pressed or if both the buttons are pressed at one time.

    So based on the button press, i can decide and move into my logical states accordingly.

    Once when i decide this condition of the button press, then i would configure the port to the digital interrupt for further button press.

    Regards

    Suresh

  • In that case, all you should need to do is write to the corresponding bit field in APCFG and then run a ADC conversion by writing to ADCCON3.

    Regards,
    Svend

  • Hi Svend,

    I already did those configurations.

    The problem which i'm facing is:

    I'm trying to use on of the button as Power button(Vdd) and the other button as mode button.

    So sometimes, it doesn't recognises the specific button, say for instance If the power button is pressed, it doesn't recognises this button and even when the mode button is pressed, it assumes that the power button is pressed and the device is turned off completely and sometimes the vice versa..

    Regards

    Suresh