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.

CCS/TMS570LC4357: How do I just turn a pin on?

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN,

Tool/software: Code Composer Studio

I'm looking to just enable a pin (perhaps an LED or one of the pins around the perimeter of the board) without using HalcoGen and just using C code in CCS.

What is the syntax for this sort of thing? 

Some people online are doing things like this:

output_high(pin_d6);

while others are doing this:

d6 = 255;

There are so many different ways that people seem to be doing this, and I'm just wondering what is the correct way for this device/IDE? Are there really no resources for learning how to code in CCS, or am I just having trouble finding them?

  • Hello Nikola,

    I recommend you using HALCoGen generated APIs. What HALCoGen generated functions are doing is exactly what you want to do.
    APIs for controlling GIO ports are in gio.c file.
    For example:
    gioSetBit(gioPORTA, 7, 1) will output high the GIOA 7 (ball M1 that is exposet at pin 5 of connector J1).
    What gioSetBit does in this case is to write 1 to bit 7 of GIODSET register for output high on corresponding GIO pin ( port->DSET = (uint32)1U << bit; ). To make output low gioSetBit(gioPORTA, 7, 0) will write "1" to bit 7 of GIODCLR register ( port->DCLR = (uint32)1U << bit; ).
    Here is how gioSetBit handles this:

    void gioSetBit(gioPORT_t *port, uint32 bit, uint32 value)
    {
    /* USER CODE BEGIN (5) */
    /* USER CODE END */

    if (value != 0U)
    {
    port->DSET = (uint32)1U << bit;
    }
    else
    {
    port->DCLR = (uint32)1U << bit;
    }
    }


    In case you don't want to call gioSetBit, you should do exactly the same - writing 1 to GIODSET for output high on pin or writing 1 to GIODCLR for output low on pin.

    After installing HALCoGen you can find some examples under HALCoGen examples folder. Description how to set and run this examples canm be found in HALCoGen Help-->Help Topics-->Examples.

    GIO ports of TMS570LC4357 and all registers are described in Chapter 25 of device TRM : www.ti.com/.../spnu563a.pdf

    If you are going to drive external circuitry please, consider maximum output strength of MCU GIOs (see device Datasheet: www.ti.com/.../tms570lc4357.pdf).


    Best regards,
    Miro
  • Thanks for the help!

    I noticed, though, that there is just the option to set the pin as "high".

    Is there a way to choose the amount of voltage being outputted through that pin? Say, for example, 1.5V instead of the full 3.3V?

  • Hello Nikola,
    Output voltage can be High - 3.3V ( minimum 0.8*Vccio ) and Low - 0V ( maximum 0.2*Vccio ).

    There is no way without external components to output 1.5V.

    Best regards,
    Miro
  • Is there perhaps a way to do it with the analog pins?
  • Hello,
    Hercules MCU does not have DAC module!
    ADC module pins are analog inputs.
    TMS570LC4357 features are listed in device datasheet: www.ti.com/.../tms570lc4357.pdf
    Detailed explanation on all modules can be found in device TRM: www.ti.com/.../spnu563a.pdf

    Best regards,
    Miro