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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/05/11 12:20
Read: times


 
#183216 - delayRS()
Responding to: ???'s previous message
how long is that delayRS?
If==halfbit( i suppose this from function rec_byte)
, then Your sender produces too short start and stop bits.

If==onebit , then Your receiver "rec_byte" is not very precise;

See code for additional comments.
regards

void send_byte(unsigned char x)
{
	unsigned char i;

	RCAP2L = TL833;
	RCAP2H = TH833;
	TL2 = TL833;
	TH2 = TH833;
	
	dat = x;
	TX = 0;

        ???????????
	delayRS();

	for(i=0;i<8;i++)	
	{
	        TX = out;
		delayRS();
		dat = dat >> 1;			 
	}
	TX = 1;

        ?????????????????
	delayRS();
	
}
// RX function
void rec_byte(unsigned char *x)
{
	unsigned char i;
	bit t=1;
	//T2CON = 0x00;
	RCAP2L = TL416;
	RCAP2H = TH416;
	TL2 = TL416;
	TH2 = TH416;


	din = 0;

        waitagain:  //?????????

	while(RX == 1);
         
       // check in the middle of start bit!!!!!!!   
        delayRS() ;//half bit
        if (RX==1) goto waitagain; //????????


        ?????????????
	delayRS();delayRS();delayRS();	   // 1.5 bit delay

	for(i=0;i<8;i++)
	{
		in = RX;		   //sample bit
		din = din << 1;
		delayRS();delayRS();	   // 1 bit delay
	}
	*x = din;

        //?????????
	delayRS();
        //here You can check validity of stop bit!!!
}




void main()
{
	unsigned char i,send[]="SEND A CHARACTERn�15",rec[]="character recieved:";
	unsigned char input='0';
	
	TX = 1;
	T2CON = 0x00;
	RCAP2L = TL833;
	RCAP2H = TH833;
	TL2 = TL833;
	TH2 = TH833;
	while(1)
	{	
	while(send[i])
		{
			send_byte(send[i++]);
			//delay1us(400);
		}
		i=0;

		rec_byte(&input);

		while(rec[i])
		{
			send_byte(rec[i++]);
			delay1us(50);  //????????? too short pause
                                       // allowed, but  too short
                                       // make delayRS()
		}
		send_byte(input);		
		i=0;
	}	

}
 


 


List of 30 messages in thread
TopicAuthorDate
bit banging program touble            01/01/70 00:00      
   why?            01/01/70 00:00      
      i need a second serial port            01/01/70 00:00      
         something like this , without any warranty :            01/01/70 00:00      
         a good start would be ...            01/01/70 00:00      
            only 3 'U's are commingout of 100            01/01/70 00:00      
               Separate the characters and look with scope            01/01/70 00:00      
                  finally it worked            01/01/70 00:00      
                     uart receiver in software            01/01/70 00:00      
   No I/O or No Timing            01/01/70 00:00      
      "No I/O or No Timing"            01/01/70 00:00      
   Someday you will learn...            01/01/70 00:00      
      this isnt the actual code            01/01/70 00:00      
         Well then another lesson to learn...            01/01/70 00:00      
   Assembler Manual will help you            01/01/70 00:00      
      assembler manual?            01/01/70 00:00      
   Data is 8 Bit??            01/01/70 00:00      
   Bit width timing and timer TH0,TL0 Values            01/01/70 00:00      
      checked values for TH0 and TL0            01/01/70 00:00      
         keil baud rate Calculator not for bit bang            01/01/70 00:00      
   LSB first            01/01/70 00:00      
   now reception....            01/01/70 00:00      
      1) din = din >> 1            01/01/70 00:00      
         working at 1200 baud            01/01/70 00:00      
            delayRS()            01/01/70 00:00      
               why do i have to sample stop bit            01/01/70 00:00      
                  Need not, but should            01/01/70 00:00      
                  because            01/01/70 00:00      
                     Much to a real UART            01/01/70 00:00      
                  1.5 bit delay            01/01/70 00:00      

Back to Subject List