chethankp
Member level 4
- Joined
- Jan 4, 2010
- Messages
- 76
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- bangalore
- Activity points
- 1,860
Hi,
I have written a uart program to send some data to PC from atmel 89c51
I get some dummy char back when ever I send data .
if I remove sendUartdata(); from my receive interrupt , I get the proper data back .
What would be the problem ?
below is the code I am using ...
#include <REGX51.H>
#include "reg_c51.h"
char uart_data;
char *SendData ="Testing All Data";
void main (void)
{
SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */
TMOD = TMOD | 0x20 ; /* Timer 1 in mode 2 */
TH1 = 0xFD; /* 9600 Bds at 11.059MHz */
TL1 = 0xFD; /* 9600 Bds at 11.059MHz */
ES = 1; /* Enable serial interrupt*/
EA = 1; /* Enable global interrupt */
TR1 = 1; /* Timer 1 run */
while(1); /* endless */
}
void sendUartdata(void)
{
int i =0;
for(i = 0; i<16 ; i++)
SBUF = SendData;
}
void serial_IT(void) interrupt 4
{
if (RI == 1)
{ /* if reception occur */
RI = 0; /* clear reception flag for next reception */
uart_data = SBUF; /* Read receive data */
SBUF = 'A'; /* Send back same data on uart*/
sendUartdata();
}
else TI = 0; /* if emission occur */
}
I have written a uart program to send some data to PC from atmel 89c51
I get some dummy char back when ever I send data .
if I remove sendUartdata(); from my receive interrupt , I get the proper data back .
What would be the problem ?
below is the code I am using ...
#include <REGX51.H>
#include "reg_c51.h"
char uart_data;
char *SendData ="Testing All Data";
void main (void)
{
SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */
TMOD = TMOD | 0x20 ; /* Timer 1 in mode 2 */
TH1 = 0xFD; /* 9600 Bds at 11.059MHz */
TL1 = 0xFD; /* 9600 Bds at 11.059MHz */
ES = 1; /* Enable serial interrupt*/
EA = 1; /* Enable global interrupt */
TR1 = 1; /* Timer 1 run */
while(1); /* endless */
}
void sendUartdata(void)
{
int i =0;
for(i = 0; i<16 ; i++)
SBUF = SendData;
}
void serial_IT(void) interrupt 4
{
if (RI == 1)
{ /* if reception occur */
RI = 0; /* clear reception flag for next reception */
uart_data = SBUF; /* Read receive data */
SBUF = 'A'; /* Send back same data on uart*/
sendUartdata();
}
else TI = 0; /* if emission occur */
}