??? 03/10/08 10:27 Read: times |
#152067 - Easy to get wrong. Responding to: ???'s previous message |
It is easy. The 19200 baud means 52uS per bit.
Unfortunately, it's also quite easy to do it wrong. SoftTX = 1; // start bit delay_us(52); for (i = 8; i--; c >>= 1) { SoftTX = c & 1; // low bit first delay_us(52); } SoftTX = 0; // stop bit delay_us(52); 1. That would work only if the instructions between the calls to the delay routine are executed by the MCU in a negligible amount of time. Since the for-loop does quite a bit of work, and the MCU in question is a 12-clocker, this is questionable. 2. C does not give you any guarantees as far as timing goes. Write the whole thing in assembly. |