Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Need help on Debugging code

Status
Not open for further replies.

vead

Full Member level 5
Joined
Nov 27, 2011
Messages
285
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
india
Activity points
3,815
Hello
I have written program that show the message on LCD screen. I want to learn debugging skill to check the program.

Please help me with following example. How to check program and Where to set break point.
8051 and proteus . I have attached screen shot of program.

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<reg51.h>
 
    /* Data pins connected to port P1 of 8051 */
    #define  Data_Port_Pins         P2
 
    sbit    Register_Select_Pin   = P0^0;           /* Register Pin of LCD connected to Pin 0 of Port P2 */
    sbit    Read_Write_Pin        = P0^1;           /* Read/Write Pin of LCD connected to Pin 1 of Port P2 */
    sbit    Enable_Pin            = P0^2;           /* EN pin connected to pin 2 of port P2 */
 
 
    /* Function for creating delay in milliseconds */
    void Delay(unsigned int wait)
       {
          unsigned i, j;
          for(i = 0; i < wait; i++)
             for(j = 0; j < 1200; j++);
       }
     
    /* Function to send command instruction to LCD */
    void LCD_Command (unsigned char command)
    {
        Data_Port_Pins = command;
        Register_Select_Pin =0;
        Read_Write_Pin=0;
        Enable_Pin =1;
        Delay (2);
        Enable_Pin =0;
    }
 
    /* Function to send display data to LCD */
    void LCD_Data (unsigned char Data)
    {
        Data_Port_Pins = Data;
        Register_Select_Pin=1;
        Read_Write_Pin=0;
        Enable_Pin =1;
        Delay(2);
        Enable_Pin =0;
    }
 
    /* Function to prepare the LCD  and get it ready */
    void LCD_Initialization()
    {
        LCD_Command (0x38);
        LCD_Command (0x0e);
        LCD_Command (0x01);
        LCD_Command (0x81);
    } 
 
        void main()
{
  unsigned char string[15]="Great Khali";
  char *pointer = string;
  LCD_Initialization();
  while(*pointer)
        {
         LCD_Data(*pointer++);
         Delay(60);
        }
}

 

Attachments

  • debugging.png
    debugging.png
    63.7 KB · Views: 99

Read the LCD data sheet. You need to include delays before starting to initialize the LCD and between each of the initialization commands.
You will have to experiment with the 'wait' value you use as it depends on the CPU clock speed and exact compiler code in the delay loop.

Brian.
 
  • Like
Reactions: vead

    vead

    Points: 2
    Helpful Answer Positive Rating
Read the LCD data sheet. You need to include delays before starting to initialize the LCD and between each of the initialization commands.
You will have to experiment with the 'wait' value you use as it depends on the CPU clock speed and exact compiler code in the delay loop.

Brian.
This code work fine with design. I want to set break point. how to check program single step. few weeks ago I wrote the code for I2C protocols that time forum member suggest to check program by dubugging code. so I am looking help in this program
 

Hi,

I rarely use software debuggers.

I often use the hardware for debugging.
Like I2C:
Write a piece of code. Maybe I2C_START and I2C_STOP.
then test this by sending the START conditionn when an input pin (maybe connected to a pushbutton) goes LOW ....and STOP when pin goes HIGH.
Use a scope to check SCL and SDA. Look for timing , signal levels, rise time, fall time...whatever is specified in the I2C_specification_sheet for both conditions.

Then program the next piece of code. Maybe sending the ADDRESS_byte.
check timing levels and so on ... also check ACK with connected device and unconnected device... check the difference.

Then program the next piece of code. Writing to the I2C device - check - then reading from the I2C device -check - then REPEATED_START - check -
Then combine all for a complete device wirte/read access - check -...

In any case... I recommend to use a piece of paper and a pencil and write down what you expect to see ... before you see the first scope picture.
This ensures that you have a good expectation of what yo want to see .. and thus you better recognize what not is like expected.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top