NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » What am I doing wrong? (Tempsensor)
December 27, 2011 by Drwish |
So far so good, until the tempsensor project that is =P. When I flash my MCU with my code, it does not show anything on the LCD when put back to normal mode and power cycled. When I flash the example tempsensor code, everything is fine and dandy. (I'm amazed at how accurate the sensor is!) So, here's an opporutnity to try the prestigious NerdKits support. I hope you can help me out! My code:
|
---|---|
December 27, 2011 by Drwish |
Also just an FYI, my intent was to also add Celsius, but my function was giving me errors about expecting "a '<' before samples" so I decided to see if my code would run Fahrenheit first, but it didn't, and here I am. |
December 27, 2011 by hevans (NerdKits Staff) |
Hi Drwish, Do you get absolutely nothing on your LCD when you load your program? I don't really see anything in your code that would cause that. The error you were getting when you had your Celsius conversion function was happening because you misspelled uint16_t on line 60 above. Humberto |
December 27, 2011 by Drwish |
Yep nothing at all. Here are some pictures describing my progress: MCU flashed with example code MCU put into programming mode Flashing my code, completed successfully (notice the directory) rebooting in normal mode. Nothing. Reboot in programming mode, still nothing, but WinAVR is still successful in programming it. Changed some text for sake of demonstration and here we are again at square one with the example file flashed again: =( |
December 27, 2011 by Rick_S |
Do you have a screen shot of the actual compile? Try deleting the .hex, and .o file in the tempsensor_edu folder, also, delete the .o files in the libnerdkit folder. Then re-compile your program and show a screenshot of the process. I'm thinking something is going wrong or getting confused in the compile stage. Rick |
December 27, 2011 by Drwish |
Deleted the object and hex files in tempsensor_edu, tempsensor, and libnerdkit and still the same result. |
December 27, 2011 by Drwish |
Oh wait, slight change. Now after flashing my program, I still have a blank screen. When I put it back into programming mode however, I get the 2 black lines on the LCD. I then put it back into normal mode and the LCD returned to a blank state. When I put in programming mode again, I get the black lines. I repeated this about 2 more times, with the same results. Step in the right direction I suppose. |
December 27, 2011 by Drwish |
Another update: I copied and pasted the sample code into my program, replacing completley what I had, saved, compiled, flashed to my MCU and it ran like normal.This mean that it has to be a problem in my code... |
December 27, 2011 by Rick_S |
Maybe try printing something to the display after the first lcd_home() command like..
Try inserting those after line 69 in the above file. See if it displays that. |
December 27, 2011 by Drwish |
Hmm... |
December 28, 2011 by Rick_S |
Well, that means your program is working but hanging somewhere for some reason. My next step would generally be to start sprinkling that statement elsewhere to find the point at which it goes bad. This is at least progress. Rick |
December 28, 2011 by Rick_S |
Nevermind... I think I may have found your problem. Line 37 - Your adc_read function
In your while statement you coded:
And that should be
You are checking a wrong register and as such your code is hanging there on the 1st attempt at reading the ADC. ADSC is the Analog to Digital Start Conversion bit. When this bit is set, a conversion is started and it is automatically cleared by hardware when the conversion is complete. ADEN is the enable of the ADC and doesn't change from hardware. Since ADEN was set to 1 in the initialization, your code hangs because it never zero's out. Rick |
December 28, 2011 by Drwish |
Yep that seemed to do the trick! What's amazing is that wasn't the first time I made that mistake. I guess somewhere in mind, Enable and Start Conversation are too similar. Thanks Rick, Humberto. =) |
December 28, 2011 by hevans (NerdKits Staff) |
Great catch Rick! I've been scratching my head about this one for a whole day! Humberto |
December 28, 2011 by Rick_S |
Thanks I knew after I saw it display the I'm Here message I had told him to add, that it had to be something simple. I'm just glad to have come home from work to see it working for him. Rick |
December 28, 2011 by Rick_S |
Drwish, did support live up to your expectations?? |
December 28, 2011 by Drwish |
It sure did! |
Please log in to post a reply.
Did you know that negative numbers are represented in two's complement notation in binary? Learn more...
|