This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Led GPIO34 - GPIO31 ON and then OFF

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

I need to be really sure about the behaviour of LEDS.

Which code is used to power on the LEDs? And then power off?

I haven't the oscilloscope at the moment in order to investigate, and I need to power on the led and, after some function, to power off them.

What about the code, withouth using 'toggle'?

Thank you in advance

  • Which device?

    There are examples that toggle the LEDs in controlSUITE (www.ti.com/controlsuite) for particular devices.  For example if you were using a 2803x I might suggest looking at this example:

    C:\ti\controlSUITE\device_support\f2803x\<version>\DSP2803x_examples_ccsv4\timed_led_blink

    In general pulling the pin high will turn the LED on and pulling the pin low will turn the LED off (or vice versa depending on hardware).

    Assuming you are talking about a 28x and not an M3, you can do this with the SET, CLEAR or TOGGLE registers.

    Regards

    Lori

  • Hi,

    The device is f28035.

    By using toggle, in order to power on the led gpio34 and gpio31, which is command?

    I implemented just a simple line command for each led in a function, but nothing happens. 

    I have to include some library in the function too?

    Thank you in advance,

    Pietro

  • Pietro Luigi Carotenuto said:
    I implemented just a simple line command for each led in a function, but nothing happens. 

    What does the code look like? 

    Did you configure the GPIO MUX so the pins are outputs?

    Try the example I mentioned?  It has everything you need including all of the device header files.

    In the example I mentioned the code to set the MUX for GPIO34 is shown here:

    // Configure GPIO34 as a GPIO output pin
       EALLOW;
       GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;
       GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;
       EDIS;


  • Hi,

    I need to set the Gpio 18 (or other line), 31,34 as output at the beginning of my code.

    So I calculate the following parameters:

    EALLOW;
    GpioCtrlRegs.GPBMUX1.all &= 4294967247U;
    GpioCtrlRegs.GPBDIR.all |= 4U;
    EDIS;
    
    
    EALLOW;
    GpioCtrlRegs.GPAMUX2.all &= 4294967247U;
    GpioCtrlRegs.GPADIR.all |= 262144U;
    EDIS;
    
    EALLOW;
    GpioCtrlRegs.GPAMUX2.all &= 1073741823U;
    GpioCtrlRegs.GPADIR.all |= 2147483648U;
    EDIS;
    
    
    Is it correct?
    
    
    Thank you in advance
  • Pietro Luigi Carotenuto said:
    I need to set the Gpio 18 (or other line), 31,34 as output at the beginning of my code.

    Pietro Luigi Carotenuto said:
    GpioCtrlRegs.GPBMUX1.all &= 4294967247U;

    Pietro Luigi Carotenuto said:
    GpioCtrlRegs.GPAMUX2.all &= 4294967247U;

    The MUX setting for  GPIO is 0.  I'm not sure why you are setting any bits to 1 in the MUX registers.

    Pietro Luigi Carotenuto said:
    GpioCtrlRegs.GPBDIR.all |= 4U;

    Yes, this sets the direction for GPIO34 to output.

    Pietro Luigi Carotenuto said:
    GpioCtrlRegs.GPADIR.all |= 262144U;

    When working with bits, it is easier to see which are set using a hex number.  Your calculations don't look right. 

    For the bit to turn GPIO18 to an output it would be 0x00040000

    For GPIO31 it would be 0x80000000

    For a combined value of 0x80040000.

    Or you could just let the compiler set each bit field as shown below:

       EALLOW;
       GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 0;  // GPIO
       GpioCtrlRegs.GPADIR.bit.GPIO18 = 1;   // output
       GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 0;  // GPIO
       GpioCtrlRegs.GPADIR.bit.GPIO31 = 1;   // output
       GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;  // GPIO
       GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;   // output
       EDIS;