We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi I am new to keil's uvision software, and as such have been trying to work through the demo programs from keil.
The problem I am having is that I want to display the A/D value of the potentiometer on the lcd screen on the mcb 2300 eval board. I have downloaded the blinky demo program from keil, and I can kinda see how the bar graph is displayed. But I am struggling to understand how to put the voltage on the top line of the lcd screen. I could really do with some help on this.
I have managed to use the ADC demo program to display a temp value on the uart output 2. Can I simply add this file to the blinky program and somehow print the value to the lcd screen?
Any assistance would be gratefully received.
Many thanks from a frustrated beginner.
I just do not know how to print the A/D value to the lcd display on the top line.
In the blinky demo i can see the lcd_print (" MCB2300 DEMO ");
however i want to print the A/D value from the potentiometer on the top line.
So you know how to print, but not how to replace "MCB2300 DEMO" with "Value: 147"?
One alternative is to use sprintf() (or the much safer snprintf() for all platforms where it is available to avoid problems with buffer overflows) to print into a character array and then print this character array instead of the "MCB2300 DEMO" text.
Another alternative is to manually build the text string. Something like:
... my_string[FIRST_DIGIT_POSITION] = '0' + value / 1000; my_string[FIRST_DECIMAL_POSITION] = '0' + (value / 100) % 10; my_string[FIRST_DECIMAL_POSITION+1] = '0' + (value / 10) % 10; my_string[FIRST_DECIMAL_POSITION+2] = '0' + value % 10; ...
how do i sprintf() the A/D value to the lcd screen though. That is where I am baffled?
Thanks.
Have you checked the manual?
http://www.keil.com/support/man/docs/armlib/armlib_cihfffbc.htm
You do not snprintf() the value to the display. You snprintf() the value into a text variable - an array of characters. That text string may then be sent to the display.
It is of course possible to write a mydisplay_printf() that will create formatted output and directly send it to the display. But leave that as a later step. First learn how to produce a text string, and how to send a text string to the display.
Just an addendum - this world would need a lot fewer security updates if people learned to use snprintf() when it is available, instead of the older sprintf() function.
It doesn't matter if it is school work or critical software - how long do you think it will take you to find the bug when a buffer overflow in a sprintf() call results in one or more other variables getting magically changed just because they happen to be stored directly after the text buffer in memory?