This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Second serial for 2051

Hi...
I need to have 2 serial ports on my 2051. First to communicate with PC (at 9600) and second to communicate to another device (at 1200). As I think I need to write something like bit-bang function with some time delays to reach a wanted baudrate. I think it would be like:


unsigned char port_read (void)
{
unsigned char i,a;
for (i=0;i<8;i++)
{
a = a | P1_7;
a = _cror_(a,1);
delay (?);
}
return a;
}


Data comes from lowest bit(bit 0,1,2..7) and 2 bytes in one session. Baudrate=1200. (I can stop transmition after 2 bytes received until I want to read another 2 bytes).
I read data from P1_7. How to calculate delays for stabile work ? XTAL=11059200

For delay function is it enough to make like (for i=0;i<300;i++) nop;
or I need to use an interrupt driven time generating ?

Thanks

0