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
You can generate those baudrates exactly with an 11.0592MHz XTAL.
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 ? The problem with bitbangers is that they can not be disturbed when running. You have 2 possibilities: 1) delay loops or timer control with all interrupts disabled 2) timer control with timer interrupt as the only ISR at highest priority. Erik
May be C code, please ?
You might try here: http://www.programmersheaven.com/zone5/cat27/2369.htm
May be some one have realy working C sample of implementing second serial for 2051 ? 'Cause I'v get no stable reading... Thanks