View Full Version : GPIO as Serial Interface
nasiramas
02-19-03, 04:48 PM
Hello:
Has anybody ever attempted to convert the GPIO pins on the ISOPOD to function like SCI through software?
I am looking for a generic algorithm to accomplish that.
Thanks,
Yanto
RMDumse
02-19-03, 05:00 PM
Certainly bit banging serial is possible, and I've done it in the past on 65F11 and F68HC11 processors. Haven't done it yet on the DSP in the IsoPod(TM). One of the things we are considering adding to the language before making V1.0 release is a software driven serial interface on the GPIO. Let me ask you, how many extra serial channels do you think you'd like to have on the GPIO, and at what baudrates?
nasiramas
02-19-03, 08:25 PM
Thanks for responding.
I am going to need at least two more serial TTL lines. The baudrate are 9600 and 2400.
- Yanto
RMDumse
02-20-03, 02:27 PM
Originally posted by nasiramas
...to convert the GPIO pins on the ISOPOD to function like SCI through software?
I am looking for a generic algorithm to accomplish that.
Okay, basically to generate a UART in software requires a periodic interrupt. I guess a scan loop could be used too, but I've never done it that way. You interrupt at a multiple of the frequency you want to receive. The absolute minimum (which may surprize some) is 3x the rate. Little know fact, odd multiples work much better than even multiples. But from the history of hardware, even dividors being easier to create, usually people do 8x or 16x the serial speed.
So to detect the start of a serial byte, you look for the line going low, then you time to 1/2 bit time, and check again to see if it is still low. If still low, you assume you've got a start bit, and time a full bit time eight more times (assuming 8 bit data), and take the line, high or low, as bit to shift into a line of bits. You can check one more time to verify a stop bit. Then you restart looking for a low, to begin the process again.
You could do a serial out using the same higher speed clock, but you could also just use a 1x rate. Normally the output line will idle high. First set the line low for on bit time, then set a bit at a time for each bit in the outgoing data, then set the line high and count off one more bit time for the stop bit.
Just to be sure that if you are using interrupt, you have to select one of the highest priority to not be interrupted by an other one.
For me, the highest speed is targeted to use the Isopod as a bridge between networks and computer. If it's possible, a USB or Ethernet interface can greately accelerate data transfer.
vBulletin v3.0.7, Copyright ©2000-2012, Jelsoft Enterprises Ltd.