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/TM4C123GH6PM: Getting a value to pass into the Kentec display

Part Number: TM4C123GH6PM


Tool/software: Code Composer Studio

Hello,

I am working with the kentec display on the tm4c123 MCU. I would like to pass a value into the touch screen from a rpm measurement calculated. I am working with this code now.

I have this working, but i have ASCII character displaying instead of the "RPM: %d/0". 

this is the canvas i have to display the function created above.

I am trying to get a value updating to show the rpm that was measured from the bike. The code compiles correctly, but i am not getting the value i want to display on the screen. I have read in the grlib, but haven't found much help there with writing this. Any suggestions? 

Thanks,

Mike

  • Hi,
    I think there are two issues, may or may not be related to your problem. First of all the rpm is not initialized inside the function so it will be unknown when you pass the rpm into the usprintf(). Secondly, the size of the timer is only 2 characters as in char timer[2]. The string you are trying to print occupies more than two characters. For example, you string has 'R', 'P', 'M', ':', and the characters to represent the rpm value. It will be more than 2 characters. You maybe printing unknown values which occupy the memory space after the timer[2].

  • Hello,

    I changed the string size I wasn't sure what exactly that was for, but I see now that its for the size of what im displaying. The calculations I have for the rpm are under the variable "timer" I want to display that value. I am not sure how to initialize rpm inside of the function? I was getting a warning saying that it was being used before initialized. I am getting an ASCII value of @. that is being displayed. I think if I initialize the rpm like you said it should work better. Or do I need to use the "timer" value since that has the numbers that I would like to display.

    Thanks,
    Mike
  • Hi Michael,
    You can not leave the variable 'rpm' uninitialized before you call usprintf(). I wonder why you are not passing the rpm variable as an argument into the PrintRPM().
  • Hi Charles,

    I am not sure why I am not getting a value I will initialize it, and see if that makes a difference. If it does not is there anyting else that I could do? Am I using the correct code to display something like this?

    Thanks,
    Michael Winter
  • Hi Michael,

    If you call PrintRPM() does it print properly without using the Canvas widget?

    Can you put a breakpoint after the usprintf() and show what is stored in the timer variable. If not yet done so, you can right click the timer variable and then add the variable to the expression window.
  • Hi Charles, 

    I am working now on calling it without using the canvas widget now. should i just put the PrintRPM(); in the while loop in main? I do have a watch expression to see what is being displayed for my timer value. I can see that it has data in it from my inputs so that definitely works. 

    Thanks,

    Michael Winter 

  • Hello Charles,

    I tried calling the PrintRPM(); in main, and it did not work. The values i have, and want to display are in the variable timer. I have made that a global variable so it can be used in the equation to get the value, and then in the function as well. I edited the function to this now. Is this correct to display timer? 

    Thanks,

    Mike 

  • You need to increase the size of "string". I suggest you use string[10]. That is 4 for the "RPM:", 1 for the space, up to 4 for the number and one for the null on the end. Don't worry about wasting RAM space. This will be in temporary (stack) space as it is a local.
  • Hello Bob,

    I did adjust the string size to 10, and it is still not displaying correctly. It is showing D. Could there be a problem with passing this function into a canvas. The GrStringDraw puts it to a location, and then the canvas has its own location too. Should i match them together?

    Thanks,
    Mike