- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Tags:
- gpios
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks...
So I got that all working. However, in my case statement inside the gpio handler I am getting 0x28 (40 dec) as the GPIO that triggered the IRQ. However, I defined the IRQ as P24 (yes, the logical P24) so I'm pretty sure that isn't the case. Does this make sense to anyone?
Thank You,
George
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The value returned is a bit mask. Bits 4:0 is the pin number and bits 6:5 is the port number.
0x28 >> 5 = 1 = port 1
0x28 & 0x1F = 8 = pin 8
Port 1, Pin 8 is P24.