5Mbit/sec ASCII streaming from/to Hub RAM
Hi All;
The following short routines·let sequential byte data stored in Hub·RAM·be·transmitted·or received to Hub RAM at 5 Megabaud in standard ASCII form; start, 8 data and stop. The code has been tuned so the Hub read and writes occur during the stop bit,·and other overhead matters such as pointer handling, bit counting, byte counting and end-of-string zero·detection is interleaved in the code.·Essentially, by judiciously positioning the instructions, all overhead has been eliminated, and the routines can stream for any length.
Packets from 1 to 2^32 bytes can be accomodated, albeit·for receiving, presumably only·some maximum less than the Hub's 32K RAM size is practical, as the destination buffer is not circular. Perhaps circular buffers can be added.
The receive routine·can use·different start-search periods·for searching for the first start bit of a packet, and subsequent start bits, hence end of packet detection. The routine returns after no-data time-out, or collecting the prescibed number of bytes, or incomplete number of bytes. The transmit routine returns on completing·the specified byte count, or on·reading a zero from the Hub RAM in the case of zero terminated strings.
Three routines are attached, the first (displayed here) is the Hub5MbsTx, that repeatedly transmits a packet, and that should be programmed into one Prop.
The second is the Hub5MbsRx receive routine (not used in this demo code) that would collect data and store it in Hub RAM.
The third, Hub5MbsRxTx,·should be programmed into another Prop. It·is a repeater that receives the data into Hub RAM, and on completion (or time-out) retransmits the content of the Hub's receive buffer so the contents can be compared to the original data from the first Prop. I used an oscilloscope.
Although·these routines could presumably all reside in different Cogs in one Prop, but then transmit/receive clock and hub synchronization delays would not be random, and hence not as robust a test as using two Props with independent clocks.
I'm still looking to add simultaneous checksum characters to the process, but that will need to wait for some time to come free before I can tackle that.
Anyhow, I'm enjoying the Prop assembler and hope someday to get my head wrapped around SPIN!
Edit to bump post.
Cheers,
Peter (pjv)
Post Edited (pjv) : 2/25/2010 5:03:05 PM GMT
The following short routines·let sequential byte data stored in Hub·RAM·be·transmitted·or received to Hub RAM at 5 Megabaud in standard ASCII form; start, 8 data and stop. The code has been tuned so the Hub read and writes occur during the stop bit,·and other overhead matters such as pointer handling, bit counting, byte counting and end-of-string zero·detection is interleaved in the code.·Essentially, by judiciously positioning the instructions, all overhead has been eliminated, and the routines can stream for any length.
Packets from 1 to 2^32 bytes can be accomodated, albeit·for receiving, presumably only·some maximum less than the Hub's 32K RAM size is practical, as the destination buffer is not circular. Perhaps circular buffers can be added.
The receive routine·can use·different start-search periods·for searching for the first start bit of a packet, and subsequent start bits, hence end of packet detection. The routine returns after no-data time-out, or collecting the prescibed number of bytes, or incomplete number of bytes. The transmit routine returns on completing·the specified byte count, or on·reading a zero from the Hub RAM in the case of zero terminated strings.
Three routines are attached, the first (displayed here) is the Hub5MbsTx, that repeatedly transmits a packet, and that should be programmed into one Prop.
The second is the Hub5MbsRx receive routine (not used in this demo code) that would collect data and store it in Hub RAM.
The third, Hub5MbsRxTx,·should be programmed into another Prop. It·is a repeater that receives the data into Hub RAM, and on completion (or time-out) retransmits the content of the Hub's receive buffer so the contents can be compared to the original data from the first Prop. I used an oscilloscope.
Although·these routines could presumably all reside in different Cogs in one Prop, but then transmit/receive clock and hub synchronization delays would not be random, and hence not as robust a test as using two Props with independent clocks.
I'm still looking to add simultaneous checksum characters to the process, but that will need to wait for some time to come free before I can tackle that.
Hub5MbsTx
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
long Cog
PUB main
cognew(@MainProg, 0)
CON
ScopeBit4 = 1 <<4
ScopeBit5 = 1 <<5
ScopeBit6 = 1 <<6
TxLine4 = ScopeBit4 'transmit data line
TxCommence5 = ScopeBit5 'show duration transmission active
TxBitTime6 = ScopeBit6 'show bit duration.... actual position is 2 instructions later
TxRepDelay = 12 'how long to wait before transmitting
'TxByteExp = 0 'dump 1 byte
TxByteExp = 4 'dump 16 bytes
'TxByteExp = 8 'dump 256 bytes
'TxByteExp = 14 'dump 16K bytes
'TxByteExp = 16 'dump 64K bytes
DAT
'MainProg ==============================================
'Ser1al ASCII transmitter dumps from main ram at 5 Mbits/sec (2 usec per byte) in one continuous stream
org 0
MainProg mov dira,#$FE 'port bit 0 input
or outa,#TxLine4 'set transmit uart to stop condition
OnePass mov HubAddr,#0 'start dump from main at 0
mov ByteCtr,#1 '
shl ByteCtr,#TxByteExp 'dump selected number of bytes consecutively
xor outa,#TxCommence5 'show transmit string commence pulse on scope
call #HubTx5Mbs wz 'clear zero and send the stream
mov Temp,#1 '
shl Temp,#TxRepDelay 'how long before transmitting again
add Temp,cnt '
waitcnt Temp,#0 '
jmp #OnePass 'do it again
'Transmit Streamer Routine ============================
TxOneBit xor outa,#TxBitTime6 'optional scope bit time indicator.. replace with nop
shr Shifter,#1 wc 'get bit
muxc outa,#TxLine4 'output it
djnz BitCtr,#TxOneBit 'test for 8 bits done
sub ByteCtr,#1 wz 'keep track of how many done
HubTx5Mbs or outa,#TxLine4 'stop condition
rdbyte Shifter,HubAddr 'get value from Hub RAM
'optionally rdbyte Shifter,HubAddr wz 'get value from Hub RAM and exit on zero terminated string
add HubAddr,#1 'next byte address
OneByte if_nz andn outa,#TxLine4 'start condition
mov BitCtr,#8 'how many bits
if_nz jmp #TxOneBit +1 'loop for another byte
HubTx5Mbs_ret ret 'done
Temp long 0
ByteCtr long 0 'how many bytes to receive/transmit
HubAddr long 0 'start location in Hub RAM
Shifter long 0 '
BitCtr long 0 '
Anyhow, I'm enjoying the Prop assembler and hope someday to get my head wrapped around SPIN!
Edit to bump post.
Cheers,
Peter (pjv)
Post Edited (pjv) : 2/25/2010 5:03:05 PM GMT

