11 Replies Latest reply on Jun 18, 2014 8:37 PM by jareddlc

    Can someone tutor me on GPIO usage?

      Hello everybody, As I mentioned before, I am new to this type of programming. I've mainly programmed arduino's which is a joke compared to this chip. I am having alot of difficulties in converting my arduino code to be used with broadcom chip. For the time being what I need to do is GPIO. at the press of a button, turn on an LED, simple enough right? we'll im stuck with not being able to turn on the LED or figure out if my pins are correct.

       

      If anyone has some time and would like to run my through the basics of this devkit and chip I would really appreciate it. We can meet online via skype or something alike.

        • 1. Re: Can someone tutor me?
          jota_1939431

          Hello jareddlc,

           

          Have you tried looking at the QSG?

          The specified item was not found.

           

          Let me know if this helps.

           

          JT

          • 2. Re: Can someone tutor me?

            thanks jota_1939431, I read that and I up and running. My questions were in particular to get going with GPIO, and later receiving text data from bluetooth. Currently I'm focused on learning the GPIO portion.

            • 3. Re: Re: Can someone tutor me?
              jota_1939431

              Hello jareddlc,

               

              Lights...Music...Action!  You decide:

               

              MidTerm Exam:

               

              1. Go to the pwm_tones SDK example


              2.  Replace the attached file

              3.  Tell me what you hear??

               

              Send me back the explanation.

              [HINT] - GPIO connected to Buzzer

               

              Thanks JT

              • 4. Re: Re: Re: Can someone tutor me?

                Thanks, I've already ran that example.  I'm taking portions of it to try to build my code. please see my code at: turq

                 

                So what i've done, is trying to use the built in button, to toggle an external LED. I've read the doc references for the functions and I dont quite understand the following:

                 

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

                 

                • what is the purpose of dividing by 16 and modulo of 16.
                • I couldnt find a reference to the flag 'GPIO_OUTPUT_ENABLE'

                 

                I dont have an Oscope to check if my pins are changing. I am using the diagram i posted for GPIO as my reference, which im now starting to think it is incorrect

                 

                I would like to add a timer in between to be able to wait 250ms, 1000ms, before proceeding to turn turn off led.

                • 5. Re: Can someone tutor me?
                  ArvindS_76

                  void turquoisebicuspid_blink_led1(void)

                  {

                      ble_trace0("turquoisebicuspid_blink_led1()");

                      bleprofile_LEDBlink(250, 250, 2);

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

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

                  }

                   

                  The default LED setting is to use P14 (see GPIO_PIN_LED in platform.h). Can you confirm D3 is installed on your tag board (this should be between the eight dipswitches and the GPIO header)?

                   

                  TURQUOISEBICUSPID_LED1_GPIO is defined as P26. What is this connected to? P26 is brought out to J8.4. You need a scope or a logic analyzer to see the signal (or hook up an LED to it).

                   

                  > what is the purpose of dividing by 16 and modulo of 16.

                  All GPIO API operate on ports and pins. There are 40 GPIOs arranged in three ports in the SoC - Port 0, Port 1 and Port 2. Ports 1 and 2 have 16 pins each and Port 2 has 8. So P26 is port 1, pin 10.

                   

                  > I couldnt find a reference to the flag 'GPIO_OUTPUT_ENABLE'

                  See <SDK>include/Drivers/gpiodriver.h

                   

                  >I would like to add a timer in between to be able to wait 250ms, 1000ms, before proceeding to turn turn off led.

                  See:

                  void turquoisebicuspid_reg_timer()

                  {

                  }

                   

                  This is where you have to register your timer callbacks. See hello_sensor.c for a sample:

                   

                  bleprofile_regTimerCb(hello_sensor_fine_timeout, hello_sensor_timeout);
                  bleprofile_StartTimer();

                   

                  and follow the callbacks.

                  • 6. Re: Re: Re: Can someone tutor me?

                    Thank you, so helpful. Looks like I was correct, J8.4 same as my image posted here: GPIO Headers

                     

                    In terms of D3, the LED does turn on with bleprofile_LEDBlink(250, 250, 2); I'll look into the gpiodriver.h. I briefly looked at the timer from that example, but didn't quiet understand. I'll give it a shot and post some of my code. Could I connect a multimeter and check to see if P26 is changing?

                     

                    i'll try to see If the status if my P26 is changing, and will try to learn how to do a timer.

                    • 7. Re: Can someone tutor me on GPIO usage?

                      How do i change the power value of pins? currently i get 1.8V and low on 059.2mV. I want to turn on a 20mA 3V LED is it possible to change the value from 1.8V to 3V?

                       

                      Also, I added my `gpio_configurePin` in the create() function, is that bad/good? that way when i call my function that turns on LED, I can just set the pin by using: `gpio_setPinOutput`

                       

                       

                      void turquoisebicuspid_create(void)
                      {
                           //...
                           // TurquoiseBicuspid Startup
                          gpio_configurePin(TURQUOISEBICUSPID_GPIO_LED_PORT, TURQUOISEBICUSPID_GPIO_LED_PIN, GPIO_OUTPUT_ENABLE, GPIO_PIN_OUTPUT_HIGH);
                      }
                      

                       

                      void turquoisebicuspid_blink_led1(void)
                      {
                          ble_trace0("turquoisebicuspid_blink_led1()");
                          bleprofile_LEDBlink(250, 250, 2);
                          //gpio_configurePin(TURQUOISEBICUSPID_GPIO_LED_PORT, TURQUOISEBICUSPID_GPIO_LED_PIN, GPIO_OUTPUT_ENABLE, GPIO_PIN_OUTPUT_HIGH);
                          gpio_setPinOutput(TURQUOISEBICUSPID_GPIO_LED_PORT, TURQUOISEBICUSPID_GPIO_LED_PIN, GPIO_PIN_OUTPUT_LOW);
                      }
                      
                      • 8. Re: Re: Can someone tutor me?

                        I haven't quiet dug into timers yet, but given from the info above:

                         

                        bleprofile_regTimerCb(hello_sensor_fine_timeout, hello_sensor_timeout);
                        bleprofile_StartTimer();
                        

                         

                        This means these timers get called automatically every 1s and 12.5ms in their default state, correct? What would be the best way to do logic involving timing. For instance, I want to call a function that repeatedly turns on my LED every user define interval.

                         

                        Would i have to do a check in fine_timeout to see whether the condition has been met? What i really want to do is be able to do something like:

                         

                        timer(250, function* turnOn_led) or something of that nature, which allows me to control how often I'll turn on an LED. thx ArvindS_76 jota_1939431

                        • 9. Re: Can someone tutor me on GPIO usage?
                          ArvindS_76

                          The GPIO output voltage levels are the same as your Vio supply voltage. You need to use a level shifter if you want to translate this to a different voltage.

                           

                          > I want to turn on a 20mA 3V LED is it possible to change the value from 1.8V to 3V?

                          P26-P29 (on the SoC, P26-P28 on the 2073xS modules and 32 pin QFNs) can source or sink up to 16 mA. I would suggest sinking instead of sourcing, just to keep large currents from flowing through the chip and heating it.

                           

                          > Also, I added my `gpio_configurePin` in the create() function, is that bad/good? that way when i call my function that turns on LED, I can just set the pin by using: `gpio_setPinOutput`

                          Sure, this is OK to do. Though you must remember that when you configure a pin and output enable it, the output level parameter will take effect immediately. So the GPIO will be driven high in your app create function above.

                          1 of 1 people found this helpful
                          • 10. Re: Can someone tutor me on GPIO usage?
                            ArvindS_76

                            > This means these timers get called automatically every 1s and 12.5ms in their default state, correct?

                            Yes (assuming your BLE_PROFILE_CONFIG.fine_timer_interval is 12 (or 13  - it gets rounded to the closest 12.5mS interval).

                             

                            > What would be the best way to do logic involving timing.

                            You need to run a state machine in your fine timer or app timer callback - something as simple as a counter should work.

                            • 11. Re: Can someone tutor me on GPIO usage?

                              Thanks! I'll love into how to getting a 3V signal. I also need to figure how to power an RGB LED given that i've done it using analogWrite() and this feature isn't available with this chip.