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.

TM4C123G New to Code Composer Studio (Button Controller Question)

Other Parts Discussed in Thread: EK-TM4C123GXL, CC3100

Hello All,

I am VERY new to Code Composer Studio and the TM4C123G microcontroller.

I have been playing around with some of the code and have managed to get a very basic program operational. 

My current code instructs the TM4C123G to turn on the red LED for a certain amount of time and then switch to the green LED.

The GUI to accompany this code contains dials and text boxes that are bound to certain values that set the delay time for the lights. (It is similar to the CCS example "Blinky"

My next task is to create a button that turns the light off altogether. Essentially a power button for the GUI.

I have done TONS of research yielding little results. 

One example I found said to bind an onClick Event to a function written in the app.js.

I coded it exactly like the example I found and got nothing.

The button was completely unresponsive

I am fluent in C and I was wondering if there is a way to link a button's function in the main C code. 

Do I have to code function buttons in the app.js?

If not, what is the syntax for a button functionality in the main C code?

Any help is much appreciated

Thanks so much

Java Code:

require(["dojo/ready"], function(ready){
     ready(function(){
         // logic that requires that Dojo is fully initialized should go here

     });
});

function divide14814815( valueFromTarget) {
	 // return valueFromTarget/2;
	return valueFromTarget;
}

function times14814815( valueToTarget) {
	 // return valueToTarget*2;
	return valueToTarget;
}

function changetosecs( valueFromTarget) {
	 // return valueFromTarget/2;
	return valueFromTarget;
}

function changetodelay( valueToTarget) {
	 // return valueToTarget*2;
	return valueToTarget;
}

function onOff() {
	timeoff = 20000000;
	
}

Main Code:

  • Hello Brian

    Can you please explain the setup you have from the js file all the way to the LaunchPad?

    Regards
    Amit
  • Hi Amit,

    Sure!
    My TM4C123G is hooked up through USB

    I re-edited my original post to contain my java code and my main code

    Thanks
  • It should be noted: Function "onOff()" is the function my button is tied to through the onClick event.
  • Hello Brian

    My only question is how the value of "timeoff" is being parsed to the EK-TM4C123GXL LaunchPad? If the expectation is that the JS console will interact with the Code Composer Studio to parse the same to the LaunchPad, then it is not possible at run time.

    You need to have a mechanism via serial ports or via the Device USB to send the same to the Launchpad.

    Regards
    Amit
  • Amit Ashara said:
    If the expectation is that the JS console will interact with the Code Composer Studio to parse the same to the LaunchPad, then it is not possible at run time.

    You need to have a mechanism via serial ports or via the Device USB to send the same to the Launchpad.

    I wasn't sure if this example is built using GUI Composer, or some other scripting.

    The GUI Composer add-on for CCS can interact with global variables on a Cortex-M4 target at run time, by using the DAP to read/modify global variables while the target CPU continues to run.

  • Hello Chester,

    But isn't a field connection with JTAG an non viable option? There must be a rather more efficient way of doing so.

    Regards
    Amit
  • Hi guys,

    I agree that button functionality through the JS doesn't seem to be the most efficient method.
    That's why I was curious to see if there was a way to tie a function in the main code to a button in the GUI Composer

    I don't quite understand how the buttons in CCS work in general. When I click on the button, what is it calling? The app.js?

    Thank you guys for responding
    Greatly Appreciated
    -Brian
  • Hello Brian,

    Can you please attach a snapshot of what you refer to as "When I click on the button, what is it calling?"

    Regards
    Amit
  • Hi Amit,

    Sorry I should have been more clear with my terminology.

    I mean a button control.

    Created in the GUI Composer

    When I create a button and put it in my GUI and then click it while running the program, what is it calling.

    I will attach a snapshot momentarily to the original post

    Thanks
  • Hopefully this better illustrates my question

    What is happening from the time I click on the button in my program to the time an action occurs because of it.

    For example, in visual studios, when you have a button in your program, a specific on click function is created automatically for that button.
    Then you can write your code in that function so that when the button is clicked a task is performed.

    Greatly Appreciated
    -Brian
  • Hello Brian

    Though I do not yet see an example of snapshot that you refer to, but to explain: when you click a button in Visual Studio, note that you are calling resources of the PC where the application is running to process the button click. It is not modifying the settings on a remote PC unless there is a TCP/UDP stack or something similar that can call for resources on another PC.

    Regards
    Amit
  • Hi Amit,

    Ok, I think I'm starting to understand.

    How might the TCP/UDP stack be used in regards to my micro controller? (The TM4C123G)
    Could I use these stacks to have an instant modification of the micro controller's settings? And if so, how?

    Greatly Appreciated
    Brian
  • Hello Brian,

    There are quite a few methods

    1. You can use a CC3100 booster pack to get a Wifi node on the TM4C123 and then use it control the end devices like LED, etc.
    2. You can use USB Host on a PC (not a TCP/IP stack) and interact with the TM4C123 in USB device mode.

    Regards
    Amit
  • Hi Amit,

    Awesome!

    I think I might already have the USB connection sufficient for method #2.

    How can this help me code my button controller from my GUI?
    Is there a certain syntax used to write setting modifications to the board?

    Greatly Appreciated
    -Brian
  • Hello Brian,

    You can use USB example usb_bulk_example to send a packet which can have a message like 0x00 to switch off the LED and 0x01 to switch ON an LED. In the usb_bulk_example you can then process the packet to take appropriate action.

    Regards
    Amit
  • Hi Amit,

    Great news! I got it to work.

    I ended up using a button value to communicate with my main code.

    Then from there I used your method of turning the LED off which worked like a charm.

    Thanks so much for all your help!

    All the best!
    -Brian Apple