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.

[51] Programming in C language for 8051 Micro Controller

Status
Not open for further replies.
Hi,

Don´t expect answers, as long as you give undocumented code.
It seems you want to give us a riddle.

I try it anyway.

You say it depends on the "sent()" function.

Code:
    void sent()
        {   
            SBUF = 254;
            while(TI == 0);
            TI = 0;

SBUF: In your whole code I can´t find how SBUF is treated. What´s the purpose? How does it work?
TI: In your whole code I can´t find how TI is treated. What´s the purpose? How does it work? I can´t find it to be initialized. Once it is not "0" the loop obviously will be infinite.

***
Try to debug your code by setting/clearing outputs at special points in your code. With a scope you can verify if the code is executed, how often it is executed and how long it takes for the code to be executed.

For example: SET an output at the first line of your SENT() function and CLEAR it at the last line of your SENT() function.

Debug your code this way step by step, until you find the line of code that creates the problem.

***
Again: Please give COMPLETE informations. Otherwise don´t expect (much) answers.

Klaus
 

My program flow is shown as below.

In first step I initialize LCD, Timers, ADC,etc...
Then i go for sensing device and take data from their.
Then i go for calculation on which i have sensed data.
Then i go for check key press,if any key press then take action according to that other wise go for display.
In last i go for send data to PC.

Except my ADC Sensor,other sensors like proximity(for RPM Sense),frequency sensor and key matrix are working on timers and interrupts.
In RPM sensor i used timer 0 as counter and timer 1 as timing purpose. same i used timer 1 as baud rate generator.

Now i explain actual what happen with me.

When i start my routine of Serial communication at the same time my other routine of sensing like RPM,Frequency, & Key sensing routines are not working but ADC sensing and Display routine are working properly, if i disable serial communication my program can working properly.

so i want to know what happens with my code?

you can see main routine at the last from their you can see my all subroutines.
 

You posted a more than 5000 lines main.c Should be really appended as a file ...
SBUF: In your whole code I can´t find how SBUF is treated. What´s the purpose? How does it work?
TI: In your whole code I can´t find how TI is treated. What´s the purpose? How does it work? I can´t find it to be initialized.
Yes, nothing explained. Nevertheless the operation of function sent() is obvious to anyone who knows 8051. Actually the problem isn't caused by the code inside sent().

But looking down into main() we find this sequence (comments added by myself)

Code:
ES = 1; // Serial port interrupt enable
EA = 1; // Global interrupt enable
TR1 = 1; // Timer 1 run
datasend(); // Calls sent() multiple times

Means serial interrupt is enabled before sending data to the UART buffer (SBUF). TI is set and serial interrupt called at the end of the transmit frame. Unfortunately there's no interrupt function at all.

Simple question: Why are you enabling serial interrupt (or any interrupt) without defining interrupt functions?
 

Can u please explain with some example or some change in my code?

Means serial interrupt is enabled before sending data to the UART buffer (SBUF). TI is set and serial interrupt called at the end of the transmit frame. Unfortunately there's no interrupt function at all.

Simple question: Why are you enabling serial interrupt (or any interrupt) without defining interrupt functions?
 

ES is interrupt enable, it's only used for interrupt based UART handling.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top