Switching Pins in Hello Sensor Sample App

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

cross mob
Anonymous
Not applicable

Hi All,

I am trying to switch the pins on the buzzer and buttons for the hello sensor sample app. I was wondering if someone could tell me the exact lines to modify. I want to modify the buzzer to PIN26 and the button to PIN24.

I also have a question on the IRQ setup. Below I have some code to setup a IRQ handler. It works on PIN4 which I had previously set it up for but not for PIN24. This doesn't seem correct since a UINT16 could not handle 1<<24.

#define BUTTON_PIN 24

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

gpio_registerForInterrupt(masks, gpio_interrupt_handler, NULL);

Thank you,

George

0 Likes
1 Solution
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

I will assume you mean the logical pin P24 (and not the physical pin on the SoC/Module/package).

The 40 logical GPIOs are in 3 ports - Port 0 has P0-P15, Port 1 has P16-P31 and Port 2 has P32-P39. The masks array is an array of the three ports and the corresponding GPIO on that port. In general, port = P#/16 and pin = P#%16. So what you really need is:

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

gpio_registerForInterrupt(masks, gpio_interrupt_handler, NULL);

The buzzer is driven by the PWM block. See pwm_tones sample app.

View solution in original post

3 Replies