Questions and discussions about the software that runs on the TD RF module itself.
giovanni
 
Posts: 10
Joined: Mon Jun 22, 2015 1:04 pm

TD1208 Interrupt on SDA port and USR2 port

by giovanni Tue Jul 28, 2015 7:22 am

Hi,

After trying many things we I haven't been able to get interrupts from the SDA port (button) and the USR2 port at the same time on the TD1208.
The interrupt on the SDA port needs to be falling edge, the interrupt on the USR2 port needs to be rising edge.
I'm able to get them to work separately but not together.

For the button I tried using the method using the TD_TOOLS_SWITCH and the method defining the interrupt myself using the NVIC.

The code I'm using:

1) Code for USR2 interrupt
Code: Select all
---------------- Defines ----------------

#define INT_PORT   USR2_PORT         
#define INT_BIT      USR2_BIT         
#define INT_MASK   USR2_MASK      

---------------- Interrupt handler ----------------

static void ADXLInterrupt(uint32_t mask)
{
   ADXLEvent = true;
}

---------------- TD_USER_Setup ----------------

int type;   
IRQn_Type irq_acc;

// Define the INTpin as an input in input-pull mode
GPIO_PinModeSet(INT_PORT, INT_BIT, gpioModeInputPull, 1);

type = (INT_MASK & TD_GPIO_ODD_MASK) ?
       TD_GPIO_USER_ODD : TD_GPIO_USER_EVEN;
       TD_GPIO_SetCallback(type, ADXLInterrupt, INT_MASK);

GPIO_IntConfig(INT_PORT, INT_BIT, true, false, true);

// Clear and enable the corresponding interrupt in the CPU's Nested Vector
// Interrupt Controller
irq_acc = (INT_MASK & TD_GPIO_ODD_MASK) ? GPIO_ODD_IRQn : GPIO_EVEN_IRQn;
NVIC_ClearPendingIRQ(irq_acc);
NVIC_EnableIRQ(irq_acc);

---------------- TD_USER_Loop ----------------

if (ADXLEvent) {

    // sending SF TX and toggling some GPIO
         
   // Wait actively while the  INT pin is still active
   while (GPIO_PinInGet(INT_PORT, INT_BIT) == 1)
   {
         ;
   }

   // Clear the  event
   ADXLEvent = false;
}

2) Code for SDA (button) interrupt

Code: Select all
---------------- Defines ----------------

#define BUTTON_PORT      SDA_PORT         /**< Button port */
#define BUTTON_BIT              SDA_BIT         /**< Button bit */
#define BUTTON_MASK      SDA_MASK         /**< Button mask */

static uint8_t SwitchId;

---------------- TD_USER_Setup ----------------

// Push button initialization
SwitchId = TD_TOOLS_SWITCH_Init(BUTTON_PORT, BUTTON_BIT, gpioModeInputPull, true, true, 2, 5, 8);

// Start interrupt handling
TD_TOOLS_SWITCH_Start(SwitchId);

---------------- TD_USER_Loop ----------------

   switch (TD_TOOLS_SWITCH_Process(SwitchId)) {
      case TD_TOOLS_SWITCH_ON:
         break;
      case TD_TOOLS_SWITCH_OFF:
         break;
      case TD_TOOLS_SWITCH_STARTUP_PUSH:
         break;
      case TD_TOOLS_SWITCH_SHORT_PUSHED:
         break;

      case TD_TOOLS_SWITCH_SHORT_RELEASED:
         break;

      case TD_TOOLS_SWITCH_LONG_PUSHED:
         break;

      case TD_TOOLS_SWITCH_LONG_RELEASED:
         break;

      case TD_TOOLS_SWITCH_VERY_LONG_PUSHED:;
         break;

      case TD_TOOLS_SWITCH_VERY_LONG_RELEASED:
         break;

      case TD_TOOLS_SWITCH_EXTRA_LONG_PUSHED:;
         break;

      case TD_TOOLS_SWITCH_EXTRA_LONG_RELEASED:
         break;

      case TD_TOOLS_SWITCH_DOUBLE_CLICK:
         TD_Audio_Play(0);
         break;

      case TD_TOOLS_SWITCH_TRIPLE_CLICK:
         break;

      case TD_TOOLS_SWITCH_MULTIPLE_CLICK_PENDING:
            //TD_TOOLS_SWITCH_GetMultipleClickCount(SwitchId));
         break;

      case TD_TOOLS_SWITCH_MULTIPLE_CLICK_DONE:
            //TD_TOOLS_SWITCH_GetMultipleClickCount(SwitchId));
         break;
      default:
         break;
      }

One more thing I'll try now is using the TD_TOOLS_SWITCH functionality for both inputs. But I was hoping to be able to use NVIC for both interrupts. Is this possible? I've tried it using NVIC for both but didn't get it to work either.

Kind regards.
User avatar
lcheminade
 
Posts: 146
Joined: Mon May 11, 2015 7:47 am

Re: TD1208 Interrupt on SDA port and USR2 port

by lcheminade Mon Aug 03, 2015 4:00 pm

Sorry for the late answer. This is indeed not possible. I added this post to clarify this point: viewtopic.php?f=10&t=79
Return to Firmware

Who is online

Users browsing this forum: No registered users and 24 guests