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.

GPIO pin not getting 2-mA, 4-mA and 8-mA

Other Parts Discussed in Thread: TM4C1230H6PM, LM324

I am using TI microcontroller TM4C1230H6PM for my application.
we already knew that this controller have many option to save the power better than sleep mode.We are using PG3-pin 34 for led indication .
As per datasheet all GPIO pins have 2-mA drive.but When i was checked by hardware way , getting 29mA current instead of 2mA on pin no 34.The firmware for this application is set as 2mA.

Please help


0755.Schematic Prints.pdf

  • Hello Sujata

    If you go through the electrical section "Recommended GPIO Pad Operating Conditions" the current sourced is shown in the minimum column. The maximum value can reach upto 25mA and exceeding the value would mean that you are going to affect the reliability.

    Rather than sourcing the LED, use a FET/BJT and the GPIO to control the Gate/Base so that the circuit works as a Switch rather than a supply.

    Regards

    Amit

  • Hi Amit

    Thanks for the reply,

    actually our aim is to control the o.p. current of controller through API functions.
    But what we did its not matched with observation we get from the controller.

    e.g. if we set 4mA current through API and if we want to observation the source current on DMM both should matched... This is what we are expecting from the tiva TM4C123x controller? Please correct us and share your opinion to move further.

    Regards

    Sujata,

  • Hello Sujata,

    I think what you are trying to do is to use the GPIO as psuedo DAC so that by controlling the current you can light up and control the intensity of the LED? Is that a correct statement?

    Also if not, then please clarify with a simple hand-drawn application. Also a full picture of the what application you intend to do with the TM4C123 GPIO IO Current Control would be useful for the community as well.

    Regards

    Amit

  • sujata jadhav1 said:
    e.g. if we set 4mA current through API and if we want to observation the source current on DMM both should matched... This is what we are expecting from the tiva TM4C123x controller?

    The GPIO pads on a Tiva device are not constant-current. The drive strength setting is used to maximum current where the corresponding output voltage meets the VOH/VOL thresholds - see Table 20-6. Recommended GPIO Pad Operating Conditions in the datasheet for more details.

  • Hello Amit/ Chester!

    Thanks to reply,

    Our aim is to use GPIO pin of TM4C123X as a output current source, hence for, use the following function to configure one the pin of controller as a o.p.

      // Configure PD6 (O/P in) as an output.

    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_6);
    ROM_GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_6, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_OD | GPIO_PIN_TYPE_STD_WPU);

    In this API, we guess, user have the facility to control the o.p. current of pin used with the following:

    #define GPIO_STRENGTH_2MA       0x00000001  // 2mA drive strength
    #define GPIO_STRENGTH_4MA       0x00000002  // 4mA drive strength
    #define GPIO_STRENGTH_6MA       0x00000065  // 6mA drive strength
    #define GPIO_STRENGTH_8MA       0x00000004  // 8mA drive strength
    #define GPIO_STRENGTH_8MA_SC    0x0000000C  // 8mA drive with slew rate control
    #define GPIO_STRENGTH_10MA      0x00000075  // 10mA drive strength
    #define GPIO_STRENGTH_12MA      0x00000077  // 12mA drive strength

    On above ref,its raised many doubts in our mind as

    1. can we used this pin as a output constant current source?

    2. If no, then what is the use of "GPIO_STRENGTH_xx" drive strength?

    3. What are the advantages of "GPIO_STRENGTH_xx" in controller?

     

    Regards

    Sujata

  • Hello Sujata,

    Excellent questions.

    1. No, the pins cannot be used as output constant current source in this form, You will have to assemble discrete devices on the PCB to do so

    2 and 3. The GPIO drive strength is required for the IO's to be able to source/sink sufficient current when the Voltage changes providing for a faster rise/fall time when the external device is placed far off on the system

    Regards

    Amit

  • As posters Amit & Chester have well stated - use of any MCU as a, "beast of burden" is sub-optimal - and may prove destructive.

    Your objective may be far better solved via classic, op-amp methods - which may mesh nicely w/modern, MCU features.  Even basic, low cost op-amps (LM324 is one such) may be employed as a, "controlled current (or voltage) source" and may be modernized/enhanced via, "mating w/the MCU." 

    To briefly detail - by setting several MCU pins as, "Open Drain Outputs" you may employ them to, "Switch in/out" various feedback or gain-set resistors - to achieve your desired current/voltage.  (i.e. you selectively switch one side of those resistors to ground - thus changing the op-amp's output.)   

    Strategic/exact details stray from, "proper, MCU-centric" forum usage - and are vastly available on the net & w/in earlier op-amp's data sheets.  Any linear device data book also will "overflow" with circuit diagrams & usage.

    Learning to correctly "blend/integrate" the MCU to real-world applications takes some time/experience.   (and is often rewarded w/"big bucks" - thus worthwhile...)  Along these lines - use of an MCU which incorporates a 10-12 bit DAC - still meshed w/op-amp - would prove even better!  (i.e. fewer add-on components -> smaller footprint and far greater signal output resolution!)

    Should you follow the path herein suggested I'd bet that you'd gain/enhance your skills/capabilities... (yet further - non-MCU detail - seems inappropriate for any MCU based forum - especially this fine one!)

    Central to your/others' "learning" should be the, "improvement in your investigatory skills" when prompted with (one hopes) critical/relevant insights...  Via focus/study/experiment - such insights may soon become, "self-generated" (best of all!)

  • Or if you want really simple there are current loop D/A converters (SPI, IIRC).

     

    Robert

  • Dear All,
      Our aim is neither to drive as constant current source nor to drive any external modem. our main objective is to save the current when controller is in sleep mode. 
    In this mode, we wish to drive a single LED for sleep mode indication & we need to pass  a very minimal current(2mA) through this LED.
    Can you guide us, how to save power in sleep mode of controller? or is there any API function  to get the same?
     

    Sujata
  • Hello Sujata,

    The Sleep Mode of the device is supported through API's in the sysctl.c/.h file. Is it Sleep or Deep Sleep that you want to use to save current. Deep Sleep is the lowest current mode with the controller wakeup with configuration intact. The method to do controller sleep is

    1. Configure the peripherals that need to be active in sleep mode using SysCtlPeripheralSleepEnable

    2, Configure the Auto Clock Gating using SysCtlClockGating(true)

    3. Configure the Sleep Power Mode for the Flash and SRAM using SysCtlSleepPowerSet

    4. Configure the Sleep Mode LDO to drop the core voltage using SysCtlLDOSleepSet

    5. Finally enable Sleep Mode transition using SysCtlSleep

    Do have a wakeup source like GPIO so that a button press would cause it to exit the Sleep State.

    Having said that, the use of LED to indicate sleep would incur additional penalty when driven continuously. Rather use a timer with 1 sec pulse count to drive the LED which would reduce the average current

    Regards

    Amit

  • This might be a mis-reading of what you have written Sujata but I get the impression that you have no or little resistance in series with the LED. 

    You should have a resistance in series with the LED and it is the usual way of limiting the current through the LED.  You can have several different brightnesses/currents by selecting different resistors.  More fruitful perhaps is PWM but the apparent brightness is very non-linear (and you still need a resistor).

    As Amit notes even at low currents the LED is likely to be a large consumer relative to the micro's peripherals and a periodic pulse might be more useful. 

    Robert