I'm working on a buffered IRQ & TIMER driven software UART that doesn't tie up the CPU with delays. It's a first draft but seems to work and is currently only a single character. I'll post more code as I complete the full TX/RX routine with buffers.
QpinTX = PORTx.y
Put the character to be transmitted in QTXSendChar and set QTXControl = 12
Requires a TIMER interrupt at your chosen baud rate.
Code: Select all
Dim QTXSendChar, QTXControl As Byte
Interrupt ISR()
If TIMERIRQ = 1 Then
If QTXControl > 0 Then ' service the TX buffer one bit at a time
Dec(QTXControl)
If QTXControl = 11 Then ' Start bit
Low(QpinTX)
Else ' shift out byte LSB to MSB
QTXSendChar = QTXSendChar >> 1
QpinTX = STATUS.0 ' transmit overflow bit
QTXSendChar.7 = 1 ' fill with stop bit, $FF on exit
EndIf
EndIf