[GPIO] How to set pin to High, digital & analog

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

cross mob
Anonymous
Not applicable

Hey guys, I'm delving into programming this chip, I am very new and I'm referencing the pwm_tones example, but im using the wiced device configurator. I 've connected my LED as per my illustration. here

GPIO_HEADERS_JAREDDLC.jpg

with the following code:

// TurquoiseBicuspid Constants

#define TURQUOISEBICUSPID_LED1_GPIO            (26)

// TurquoiseBicuspid Function Prototypes

static void turquoisebicuspid_blink_led1(void);

here is my function:

void turquoisebicuspid_interrupt_handler(UINT8 value)

{

    // On press.

    if(value & 1)

    {

        ble_trace0("turquoisebicuspid_interrupt_handler()");

        turquoisebicuspid_blink_led1();

    }

}

void turquoisebicuspid_blink_led1(void)

{

    ble_trace0("turquoisebicuspid_blink_led1()");

    gpio_configurePin((TURQUOISEBICUSPID_LED1_GPIO) / 16, (TURQUOISEBICUSPID_LED1_GPIO) % 16, GPIO_OUTPUT_ENABLE, 0);

    gpio_setPinOutput((TURQUOISEBICUSPID_LED1_GPIO) / 16, (TURQUOISEBICUSPID_LED1_GPIO) % 16, 1);

}

I see the trace:

23:29:12 - turquoisebicuspid_interrupt_handler()

23:29:12 - turquoisebicuspid_blink_led1()

However I wasn't sure If I am using the setPinOutput correctly as my LED does not turn on. I would like to set this pin to HIGH, similar to arduino's


digitalWrite(TURQUOISEBICUSPID_LED1_GPIO, HIGH)

analogWrite(TURQUOISEBICUSPID_LED1_GPIO, 255);


Thanks in advanced. I'm calling it a night for today. I'll check tomorrow.



0 Likes
1 Solution
Anonymous
Not applicable

Hello jareddlc,

Sorry for the late response, but I just noticed you had another question here.

The TAG003 LED was de-populated by default at our factory.

If you can solder one to the pins you should be able to use it.

Thanks.

JT

View solution in original post

0 Likes
7 Replies
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

How do you want ot use the LED? Active high/low? gpio_setPinOutput is the right way to drive it high or low (none of the GPIOs can output an analog signal). If you are using the pwm_tones sample app, it configures P26 as a PWM channel. Did you remove all such code from the sample app? If you toggle the GPIO by setting output to 0 and 1 alternatively, say every 1s, can you see the GPIO toggling on an oscilloscope?

0 Likes
Anonymous
Not applicable

I don't own an oscilloscope, and I haven't got to delay timing yet. I'll look into it tonight. Do you know what timing I should be using to wait/delay every 1000ms? just for the sake of testing this really quick, if not, i'll look at some more examples to figure it out.

I generated code using the new wiced device configurator. Im just referencing pwm_tones to figure out how they used buttons and pwm. thanks

0 Likes

You don't want to wait for 1s. Use timers instead. The pwm_tones sample app already registers for a 1s timer callback. Just implement your toggle logic in tones_timeout()

Anonymous
Not applicable

will do. thanks

0 Likes
Anonymous
Not applicable

no luck

0 Likes
Anonymous
Not applicable

Here is how i have setup my gpio, according to the picture above, which I made from the docs. At this point im starting to this I made it incorrectly. As my code is not working.

https://gist.github.com/jareddlc/04850d3a9a919b1429ed

pins.jpg

the function I am trying to get to work is on line: turq 372 of the gist. Does anyone have any experience with turning on an LED with the dev kit? I would really appreciate it, if you can show me some code, as I am not having any luck.

0 Likes
Anonymous
Not applicable

Hello jareddlc,

Sorry for the late response, but I just noticed you had another question here.

The TAG003 LED was de-populated by default at our factory.

If you can solder one to the pins you should be able to use it.

Thanks.

JT

0 Likes