Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

LCD Output error PIC16F877a

Status
Not open for further replies.

Ahmed.Soliman

Junior Member level 1
Joined
Oct 22, 2010
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,434
Good Day everyone,
I need some help fixing a bug in my code , I'm writing a program to log temperature in 5 positions using thermocouples , The temperatures should be written on pc using UART , The pic16f877a should measure temperatures through time intervals defined by the user , The user will input this interval in the begining of the program using an analog stick - for example if he push forward time (seconds) increase , pull back time (seconds) decrease , Left switch to minutes instead of seconds , another left hours then days , right will go back to hours ...and so on - then move a switch to start logging .

The problem is in the output of the LCD , when the program starts it should write " Temp. LOGGER" on the first line of the lcd - alphanumerical 16 x 2 - and "Initializing..." on the second line, and while setting hours , in the first line it should write " hours " and it flickers the write arrow in case of setting days .

will i know that the problem may not be clear for you , but the lcd write completely different things or write nothing in particular situations , its not ASCII problem , I've made another program for setting time only and it worked very well.


I really don't understand the reason for this error ,I'm using mikroC to program 16f877a and proteous for simulating my project .

I will attach the proteus simulation file and the C file.


thanks for your time i really appreciate that, and sorry for my poor English .
 

Attachments


grieblm

Member level 4
Joined
May 7, 2011
Messages
75
Helped
18
Reputation
36
Reaction score
18
Trophy points
1,308
Location
Georgetown, Canada
Activity points
1,734
I would try starting with the code that works and gradually add new functions to the working code.
I would also recommend indenting your code blocks so it is easier to see the code structure. C is very picky about braces, etc. and it is very easy to have entire code segments missed by the compiler because of a missing "{" or "}".

This is how well-structured, but incorrect, code looks:


Code C - [expand]
1
2
3
4
5
for (i=0; i<10; i++)
   x += i;
   if (x < 100) {
      Output_x(x);
   }



Here's how your code looks:


Code C - [expand]
1
2
3
4
5
for (i=0; i<10; i++)
x += i;
if (x < 100) {
Output_x(x);
}



In the first example, you can tell at a glance that the for loop is missing "{}" parenthesis because of the indentation. However, in your code, this will be impossible to spot. The compiler will not complain but the code will not work correctly. It will also be difficult for someone else to help you because what you intended is not obvious.

Granted, this example is simple, but in more complex situations, having properly formatted code is even more important.

Adding some comments to the code will also help someone else understand what you are trying to do and will make code reviews much simpler.

Situations like this are quite common with C and are the cause of many mysterious problems.
 
Last edited:

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top