Setting you an interrupt on the BCM20737_LE_KIT

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,

I am looking to set up an interrupt on the BCM20737 evaluation board.

I want to read from a sensor when the signal on pin rises.

Is there some example code someone could help me with?

Regards,

Luke.

0 Likes
1 Solution
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Disable sleep as done in the spi_comm_master.c example app. Register the callback and inhibit sleep when the callback is called.

Limit the interrupt_HANDLER to a duration below 300us.

Jacob

View solution in original post

0 Likes
13 Replies
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

Since your sensor will most likely output an analog signal, I think the ADC sample that jakewtorres put together may be a good place to start: WICED Smart ADC Example

0 Likes
Anonymous
Not applicable

Hello,

My sensor is communicating with the BCM20737 via I2C.

The Int pin on my pressure sensor is either high or low depending if there is new data available.

I want to connect this pin to the BCM20737_LE_KIT, when ever it detects a rising edge do the following piece of code.

I think an ADC is not any use to me, I am interested in an interrupt.

Regards,

Luke.

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

The code below will register for an interrupt on pin 0 (generally in create function or upon init of your sensor):

         UINT16 masks[3] = {(1 << 0), 0 , 0};

         gpio_registerForInterrupt(masks, interrupt_handler, 0);

         gpio_configurePin(0, 0, GPIO_EN_INT_RISING_EDGE, GPIO_PIN_OUTPUT_LOW);

On every rising edge interrupt of pin 0, the following function will be called:

         void interrupt_handler(void* parameter, UINT8 arg) {

                 /*your code here*/

          }

See the following post for how to alter the mask to register for interrupts on a different pin:

          gpio_registerForInterrupt

Jacob

Anonymous
Not applicable

jakewtorres I tried this and have no luck.

I declared my mask:

UINT16 masks[3] = {(1 << 1) | ( 1<< 4 ), 0 , 0}; //pin 1 or pin 4?

inside in create sensor:

   gpio_registerForInterrupt(masks, interrupt_handler, 0);

     gpio_configurePin(0, 0, GPIO_EDGE_TRIGGER_BOTH  , GPIO_PIN_OUTPUT_LOW); // changed to both edges for testing

then declared this function to handle my data:

void interrupt_handler(void* parameter, UINT8 arg)

{

   bridgeoutput=printdata(Caldata(sum));

   ble_trace1("Bridgeoutput:%x",bridgeoutput);

   if (hello_sensor_hostinfo.characteristic_client_configuration & CCC_NOTIFICATION)

   {

        bleprofile_sendNotification(HANDLE_HELLO_SENSOR_VALUE_NOTIFY, (UINT8 *)&bridgeoutput, 2);

  }

}

But when probing my interrupt line, its not failing or raising and it should be.

Any ideas?

Thanks.

0 Likes

You say that the interrupt line isn't falling or rising? Does this mean that the voltage on the interrupt line never changes? If so, this is a problem with whatever is driving your interrupt line (the sensor).

Test the interrupt on the 37 side by manually driving the pin high/low with a jumper wire, and add a trace as the first line of the interrupt function to rule out everything else in the function.

Jacob

0 Likes
Anonymous
Not applicable

jakewtorresmwf_mmfae

Can the BCM20737s handle an interrupt every 2ms (roughly)?

0 Likes

The highest resolution (soft) application timer is the 12.5 ms fine timer.

This thread and others talks about the problems that can be created when trying to set the timer any lower:Re: how to set a timer at 2ms

0 Likes
Anonymous
Not applicable

mwf_mmfae Yes that's ok for the timer.

I am wondering if I set up an interrupt and have it pulled high every 2ms (500hz), is the BCM20737 capable of handling this?

I ran a test. I hooked a signal generator running at 500hz up to an interrupt. Inside in the interrupt function it would print out a number and increment for then time. I timed how long it took to go from 0count to 500counts and i got roughly 1 second. Seems to work to me. Just interested to make sure that it wont cause any other problems else where?

0 Likes

I don't know the answer, so let's wait for jakewtorres respond.

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

This may be a question for the developers. I'm not aware of a specific number that is the fastest interrupt rate. No luck scouring the documentation. If the system didn't give you trouble it's probably fine, but there are many more variables to take into account when interrupting the system that frequently. Just a few:

     - you'll never enter sleep

     - the ability to interrupt so fast is highly dependent on what the interrupt_handler contains

               -if it's too many lines of code, things will go haywire (i2c reads are likely too long)

     - It's possible that not every interrupt will be handled

               -if you overlap with the RF interval, the system can ignore the interrupt

You're likely better off getting a sensor with a larger FIFO and reading the FIFO less often.

Jacob

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Just confirmed with the developers that my above comment is valid. However, there are two additional things to note. You'll need to manually disable sleep with an interrupt that fast. And you'll need to keep your interrupt_handler to below 1ms, ideally around 200-300us. This will, in fact, allow for small i2c reads within your interrupt handler.

Jacob

0 Likes
Anonymous
Not applicable

jakewtorres

Which comment is valid?

I am doing a small I2C read (16 bits).

When you say disable sleep, you mean put it in active mode by writing to a register?

When you say keep below 1ms, ideally 200 to 300us. You are saying run my interrupt hard at 5000hz-3333hz instead of 500hz?

To me this sounds like to wrong way to be going as you are going to be spending more time in the interrupt compared to before?

Could you confirm?

Regards,

Luke.

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Disable sleep as done in the spi_comm_master.c example app. Register the callback and inhibit sleep when the callback is called.

Limit the interrupt_HANDLER to a duration below 300us.

Jacob

0 Likes