| ??? 12/13/02 09:19 Read: times |
#34379 - RE: RI stops operating after time |
I do not really know what the problem with your RI quitting working is but ... what happens when this subroutine returns the Error=TRUE indicator? Does the calling code possibly disable the UART or the baud rate generator????
I would also like to comment about your suboutine design. It is not particulary modular to combine the low level GetByte() logic with the FrameStatus logic through the use of the globals like you are doing. It would be far better to have the GetByte() routine work more like shown below and then keep the FrameStatus handling up one level in the calling code then handles the packet interpretation.
/*
** Character Receive Routine.
** Entry: Pointer to a place to put
** inputted byte.
** Return: 0 if received byte @ pointer.
** !0 if receive timeout.
**
*/
char GetByte(unsigned char *InByte)
{
unsigned int counter=0; /* timeout counter */
while(!RI)
{
if(counter > 1000) /* character timeout */
{
return(-1);
}
counter++;
}
*InByte=SBUF;
RI=0;
return(0);
}
This design permits the subroutine to be used to receive any byte, even in code that may have times when you receive things with different types of protocols. It also allows the subroutine to be cut and pasted into the next project without dragging along the logic from the next level up. Hope this helps Michael Karas |
| Topic | Author | Date |
| RI stops operating after time | 01/01/70 00:00 | |
| RE: RI stops operating after time | 01/01/70 00:00 | |
| RE: RI stops operating after time | 01/01/70 00:00 | |
| RE: RI stops operating after time | 01/01/70 00:00 | |
| RE: RI stops operating after time | 01/01/70 00:00 | |
| RE: RI stops operating after time | 01/01/70 00:00 | |
| RE: RI stops operating after time | 01/01/70 00:00 | |
| RE: RI stops operating after time | 01/01/70 00:00 | |
| RE: RI stops operating after time | 01/01/70 00:00 | |
RE: RI stops operating after time | 01/01/70 00:00 |



