Part Number: CC2640R2F
Hi ,
CC2640R2F PIN interrupt not working after once
Please provide any suggestion.
Thanking you
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.
Part Number: CC2640R2F
Hi ,
CC2640R2F PIN interrupt not working after once
Please provide any suggestion.
Thanking you
Hi,
Thank you for reaching out.
Could you please provide details on the hardware design being used? A schematic showing the hardware design of the pin would be helpful.
Also, please specify if the same issue reproduces both when using positive and negative edges.
Best regards,
Hi,
Thank you for telling me, but what does the hardware design looks like on DIO_4? I would like to see how the button creating the interrupt is used so I can reproduce and provide guidance.
Best regards,
Hi,
Here is my understanding of your description. Can you confirm? Can you also confirm no other component is at play here? The reason I am asking is because DIO4 is used on the CC2640R2F LaunchPad reference design for I2C.

Assuming my understanding is correct, you should ensure an internal pull-down is enabled.
Here is some code I wrote for you:
#include <unistd.h>
/* Driver Header files */
#include <ti/drivers/PIN.h>
#include <ti/devices/cc26x0r2/driverlib/ioc.h>
/* Example/Board Header files */
#include "Board.h"
/* Pin driver handles */
static PIN_Handle buttonPinHandle;
/* Global memory storage for a PIN_Config table */
static PIN_State buttonPinState;
PIN_Config buttonPinTable[] = {
IOID_4 | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_POSEDGE,
PIN_TERMINATE
};
/*
* ======== buttonCallbackFxn ========
*/
void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
// Your code
}
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
if(!buttonPinHandle) {
/* Error initializing button pins */
while(1);
}
/* Setup callback for button pins */
if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) {
/* Error registering button callback function */
while(1);
}
/* Loop forever */
while(1) {
sleep(1000);
}
}
I hope this will help,
Best regards,
void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
if(PIN_getInputValue(rx_intr_pin) == 1){
flag = 1;
}
}
void *mainThread(void *arg0)
{
uint8_t cnt = 0;
uint8_t flag = 0;
buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
if(!buttonPinHandle) {
/* Error initializing button pins */
while(1);
}
/* Setup callback for button pins */
if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) {
/* Error registering button callback function */
while(1);
}
/* Loop forever */
while(1) {
if(flag == 1)
flag = 0;
cnt++;
}
}
using in this format , count is not incrementing more than one
interrupt occurs only once
Hi,
I have reviewed your code and a few things look slightly off.
1- May I ask why flag is declared locally in mainThread and accesses outside of it (in buttonCallbackFxn). It does not look correct.
2- I guess cnt and flag should be volatile variables, otherwise the compiler may optimize the accesses to flag within the while(1) loop.
3- Could you please define cnt2 and increments it every time you enter buttonCallbackFxn?
4- Could you please ensure the while(1) loop does not consume all the CPU time? This could be done using a semaphore (instead of "flag") or by adding a call to sleep.
I hope this will help,
Regards,
May I ask why flag is declared locally in mainThread and accesses outside of it (in buttonCallbackFxn). It does not look correct.
yes , it is global variable only . i have declared it outside only.
Could you please define cnt2 and increments it every time you enter buttonCallbackFxn?
Will check and reply ASAP
Thanking you