NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » Getting blank screen when running program
April 04, 2010 by Ralphxyz |
My code is a modification of the temp sensor program. I have modified it to handle multiple temp sensors. This is my first C program since I wrote a simple measurement program 15 years ago so I do not have any idea if my program even works but the immediate thing is that after it compiles successfully there is only a blank screen when the program runs. Here is a the code that I have changed, everything else is straight from the tempsensor project:
return 0; } I haven't the slightest idea if the code even runs. Is there a debugger that steps through the code? Thanks I sure appreciate (and need ) your help and would really appreciate a detailed critique . Ralph |
---|---|
April 04, 2010 by hevans (NerdKits Staff) |
Ralph, where are you trying to view the output, and what do you mean by blank screen? In the code above you are not sending your output to a specific output stream. This will work correctly if you map the uart output to stdin with the following lines
This creates a stream for the uart and maps stdout to that stream. At that point you should be able to see the output if you set up putty on your computer to act as a terminal emulator. If you don't have the lines above the output to printf_P() won't be defined. Humberto |
April 05, 2010 by Ralphxyz |
Humberto, the uart_stream comes from your tempsensor code. I only showed the code I modified everything else comes straight from your working code. the blank screen is the LCD, sorry about not saying that. Does my modified code look correct? Should it work? I am just trying to get "Hello World" to appear on the LCD. Once I get some output I'll format the sensor readings. Ralph |
April 05, 2010 by Ralphxyz |
One other thing. Whenever I modify the tempsensor project code I always get the blank LCD. If I change the averaging code:
To:
Just changing i<100 to i<1000 gets the blank LCD. Ralph |
April 05, 2010 by Ralphxyz |
oops, the problem was with the change to the averaging i<1000, I had left 1000 in my code. Once I restored the i<100 I get the display on the LCD as desired. Why in the world would that change make a difference? Ralph |
April 05, 2010 by mrobbins (NerdKits Staff) |
Hi Ralph, At least in our sample code, we have the variable i defined as being of type "uint8_t". This means that it can only hold values 0 through 255. As your inner for loop tries to keep counting until it gets to 1000, it fails to ever exit that for loop, because the condition i<1000 is always true. (When i=255 and is then incremented by one, it rolls around back to 0.) You can change "uint8_t i;" to "uint16_t i;", which will let you count up to 65535. Mike |
April 05, 2010 by Ralphxyz |
Ah, that explains it! In the averaging for loop when I changed i<100 to i<1000 I got the blank LCD because it never exited the loop as you say. That is great. As long as I use i<100 everything works great! I was thinking of using the greater averaging loop as a delay to stop the LCD from flickering but I have since learned how to use a delay_ms(100000), which appears to be working. Thanks so much for your explanation. Ralph |
Please log in to post a reply.
Did you know that you can read diagnostic data from some cars with a NerdKit? Learn more...
|