Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/28/05 08:51
Read: times


 
#94039 - inetrrupt driven serial
hi,
i have a interrupt driven serial routine as below


unsigned char uchar incoming,outgoing,lastinchar; /* received/transmited messages */
bit newin,gone; /* These are global flags */
unsigned char array[10]={'a','b','c','d','e','f','g','h','i','j'};
int i=0;
void serint(void) interrupt 4 using 1
{

if(RI)
{
incoming=SBUF;
RI=0;
newin=1; /* notify the main function */
}
else if (TI)
{

SBUF=outgoing;
TI=0;
gone=1; /* notify the main function */
}
}


/* The main function */

void main(void)
{

TMOD=0x20; /* use timer1, mode 2 */
TH1=0xfd; /* 9600 baud with a 11.059mHz clock */
TCON=0x40; /* start baud clock*/
SCON=0x50; /* enable receive */
IE=0x90; /* enable serial int */

lastinchar=outgoing='x'; /* start by sendingthecharacter 'x' */
gone=0;
newin=0;

TI=1; /* Initiate the serial interrupt */


for(;;)
{
if(gone)
{
outgoing=array[i];
gone=0;
i++;
if(i==10)
break;
}

if(newin)
{
lastinchar=incoming;
newin=0;
}
} // end for

while(1)
{;;}



} // end main


even though the break statement is executed and comes to while(1),the program keeps on sending garbage at serial port,please help.

regards,
nafis

List of 10 messages in thread
TopicAuthorDate
inetrrupt driven serial            01/01/70 00:00      
   RE: inetrrupt driven serial            01/01/70 00:00      
      interrupt driven serial            01/01/70 00:00      
         It means Done            01/01/70 00:00      
         RE: interrupt driven serial            01/01/70 00:00      
            one of ways            01/01/70 00:00      
            thanks to all            01/01/70 00:00      
               RE: thanks to all            01/01/70 00:00      
   Wheel re-invention award            01/01/70 00:00      
      good subject !            01/01/70 00:00      

Back to Subject List