Hi all.. I have to make a project where i need to transfer the data's of seven segment display to other board using 89S52. I have one board where 4 seven segment display has been interfaced to port 0 of 89S52 (MAIN BOARD) using 10K External pull up resistor. i dont have the source code of this controller so cant make any changes to it. but what i have to do is, whatever things are been displayed on this seven segment have to display in again on other seven segment display located at approx 1 to 1.5 metres away. so now what i have done is, i have made two new boards one is TX board and other is RX board. the controller of TX board in connected to controller of MAIN BOARD with same pin No. Ex. P0 of Main board to P0 on TX BOARD P1 of Main board to P1 on TX BOARD P2 of Main board to P2 on TX BOARD P3 of Main board to P3 on TX BOARD
so now whatever happen in MAIN BOARD, i can keep a track on it using my TX BOARD. so again now using serial communication i need to transfer the data's from TX BOARD to RX board where again seven segment display is interfaced. when i power the system, the MAIN BOARD displays 1234 on 7 segment for 5 seconds and then it prints EROR continuously, which i need to transfer it to RX BOARD using TX BOARD. Code for TX BOARD:
void UART_Init(int baudrate) { SCON = 0x50; // Asynchronous mode, 8-bit data and 1-stop bit TMOD = 0x20; //Timer1 in Mode2. TH1 = 256 - (11059200UL)/(long)(32*12*baudrate); // Load timer value for baudrate generation TR1 = 1; //Turn ON the timer for Baud rate generation } void UART_TxChar(int ch) { SBUF = ch; // Load the data to be transmitted while(TI==0); // Wait till the data is trasmitted TI = 0; //Clear the Tx flag for next cycle. } void main() { UART_Init(9600); while(1) { UART_TxChar(P0); } }
Code for RX Board
void UART_Init(int baudrate) { SCON = 0x50; // Asynchronous mode, 8-bit data and 1-stop bit TMOD = 0x20; //Timer1 in Mode2. TH1 = 256 - (11059200UL)/(long)(32*12*baudrate); // Load timer value for baudrate generation TR1 = 1; //Turn ON the timer for Baud rate generation } char UART_RxChar(void) { while(RI==0); // Wait till the data is received RI=0; // Clear Receive Interrupt Flag for next cycle return(SBUF); // return the received char } void main() { UART_Init(9600); segment1=0; segment2=0; segment3=0; segment4=0; while(1) { P0 = UART_RxChar(); // Receive a char from serial port }
but there is a bit problem with transfer of data's, because if the display on main board shows "1234", the RX BOARD only display "1" continuously on all 4 segment and after some time when MAIN BOARD display "EROR", the RX BOARD only display "E" all 4 segment. i agree that switching of seven segment display is quite necessary, as i am not expecting to print 1234 at the time, but at least it should print 1 2 3 4 or EROR repeatedly, which agreed wont even be readable, as i am not doing any switching. is there any error with my code.
Not so much an error - it's just incomplete.
Which is not so much a problem with your code, as with your analysis of the problem.
You need some way for the 'tx' board to know which of the 4 LEDs it is currently reading, and you need some way to tell the 'rx' board which LED the transmitted value should go on.
BTW:
void UART_TxChar(int ch)
why is that an int ?
Sorry.. i agree it has to be char... Thanks.. but right now i am not concentrating on, which segment value is being sent, right now i only want to know if all the values of P0 is being sent or not. for example, initially MAIN BOARD segment prints "1234". so initially i dont need to print 1234 in my RX BOARD, first i need to check if all the four digits("1234") are being properly sent or not. and that is the error what i am getting. the MAIN BOARD print "1234", but at the same time the RX BOARD should also print "1111" and then "2222" and then "3333" and then "4444". i agree that this values wont be readable at RX board because it might change at a rapid speed. but that's what not happing. the RX board only print "1111" continuously. when the MAIN BOARD print "1234", i am only getting "1111" and missing out the other values in my next loop.
None of this has anything to do with Keil.
"i agree that this values wont be readable at RX board"
So how do you know that it isn't actually happening - and it's just that you can't see it?!
"first i need to check if all the four digits('1234') are being properly sent or not"
To do that, you will need something that can actually show you exactly what the 'tx' board is really sending.
ie, something which will definitely give you a readable display of exactly what it's receiving!
You can't rely upon your Rx board - because you don't know if that (also) has bugs...
i have even tried switching the segment just to check if i might be receiving the other characters but not able to print it, but no i am not receiving it. the display prints only "1111". i have just switched the segment randomly, without calibrating with the TX board, basically in such case my RX board should print "1234" or "2341" or others, basically it should print all the 4 characters randomly. which is not happening.
Should it?
Again, you don't seem to have identified whether the problem is:
1. In the tx board 2. In the rx board 3. both!
Again, this has nothing to do with Keil.
We know nothing about your mystery boards - so can't really give any insight there.
Do you not have teachers / co-workers / supervisors to help you?