PST Debug LITE
Andy_ouhsc
Posts: 17
Timestamp Object.spinPST Debug Lite.spinTimestamp Testing File.spin
I am trying to understand, the following attached code that starts the serial communications
between parallax and computer
1. How are bit_ticks used,
2. what does the
buffer_ptr := @rx_buffer do?
3. Finally I do not understand the @entry portion and what is it doing.
This seems important and we want to better use the serial terminal objects to
collect time stamping data.
PUB Start(baudrate, displayStyle) : okay
{{Start communication with the Parallax Serial Terminal using the Propeller's programming
connection. Waits 1 second for connection, then clears screen.
Parameters:
baudrate bits per second. Make sure it matches the Parallax Serial Terminal's
Baud Rate field.
displayStyle is determined by a value from the Display Style Constants list above.
Returns : ID of started cog, or false (-1) if no cog is available.}}
okay := StartRxTx(31, 30, 0, baudrate)
...
PRI StartRxTx(rxpin, txpin, mode, baudrate) : okay
{{Start serial communication with designated pins, mode, and baud.
Parameters:
rxpin - input pin; receives signals from external device's TX pin.
txpin - output pin; sends signals to external device's RX pin.
mode - signaling mode (4-bit pattern).
bit 0 - inverts rx.
bit 1 - inverts tx.
bit 2 - open drain/source tx.
bit 3 - ignore tx echo on rx.
baudrate - bits per second.
Returns : ID of started cog, or false (-1) if no cog is available.}}
stop
longfill(@rx_head, 0, 4)
longmove(@rx_pin, @rxpin, 3)
bit_ticks := clkfreq / baudrate
buffer_ptr := @rx_buffer
okay := cog := cognew(@entry, @rx_head) + 1
'***********************************
'* Assembly language serial driver *
'***********************************
org
'
'
' Entry
'
entry mov t1,par 'get structure address
add t1,#4 << 2 'skip past heads and tails
rdlong t2,t1 'get rx_pin
mov rxmask,#1
shl rxmask,t2
add t1,#4 'get tx_pin
rdlong t2,t1
mov txmask,#1
shl txmask,t2
add t1,#4 'get rxtx_mode
rdlong rxtxmode,t1
add t1,#4 'get bit_ticks
rdlong bitticks,t1
add t1,#4 'get buffer_ptr
rdlong rxbuff,t1
mov txbuff,rxbuff
add txbuff,#BUFFER_LENGTH
test rxtxmode,#%100 wz 'init tx pin according to mode
test rxtxmode,#%010 wc
if_z_ne_c or outa,txmask
if_z or dira,txmask
mov txcode,#transmit 'initialize ping-pong multitasking
'
I am trying to understand, the following attached code that starts the serial communications
between parallax and computer
1. How are bit_ticks used,
2. what does the
buffer_ptr := @rx_buffer do?
3. Finally I do not understand the @entry portion and what is it doing.
This seems important and we want to better use the serial terminal objects to
collect time stamping data.
PUB Start(baudrate, displayStyle) : okay
{{Start communication with the Parallax Serial Terminal using the Propeller's programming
connection. Waits 1 second for connection, then clears screen.
Parameters:
baudrate bits per second. Make sure it matches the Parallax Serial Terminal's
Baud Rate field.
displayStyle is determined by a value from the Display Style Constants list above.
Returns : ID of started cog, or false (-1) if no cog is available.}}
okay := StartRxTx(31, 30, 0, baudrate)
...
PRI StartRxTx(rxpin, txpin, mode, baudrate) : okay
{{Start serial communication with designated pins, mode, and baud.
Parameters:
rxpin - input pin; receives signals from external device's TX pin.
txpin - output pin; sends signals to external device's RX pin.
mode - signaling mode (4-bit pattern).
bit 0 - inverts rx.
bit 1 - inverts tx.
bit 2 - open drain/source tx.
bit 3 - ignore tx echo on rx.
baudrate - bits per second.
Returns : ID of started cog, or false (-1) if no cog is available.}}
stop
longfill(@rx_head, 0, 4)
longmove(@rx_pin, @rxpin, 3)
bit_ticks := clkfreq / baudrate
buffer_ptr := @rx_buffer
okay := cog := cognew(@entry, @rx_head) + 1
'***********************************
'* Assembly language serial driver *
'***********************************
org
'
'
' Entry
'
entry mov t1,par 'get structure address
add t1,#4 << 2 'skip past heads and tails
rdlong t2,t1 'get rx_pin
mov rxmask,#1
shl rxmask,t2
add t1,#4 'get tx_pin
rdlong t2,t1
mov txmask,#1
shl txmask,t2
add t1,#4 'get rxtx_mode
rdlong rxtxmode,t1
add t1,#4 'get bit_ticks
rdlong bitticks,t1
add t1,#4 'get buffer_ptr
rdlong rxbuff,t1
mov txbuff,rxbuff
add txbuff,#BUFFER_LENGTH
test rxtxmode,#%100 wz 'init tx pin according to mode
test rxtxmode,#%010 wc
if_z_ne_c or outa,txmask
if_z or dira,txmask
mov txcode,#transmit 'initialize ping-pong multitasking
'
Comments
bit_ticks and buffer_ptr are variables in the assembly language code that's loaded into a cog to do the actual serial I/O. The Start method initializes them before they're loaded into a cog by the COGNEW statement. These details are not really important unless you intend to modify the assembly language routines used. The whole idea behind using objects is to avoid dealing with the details of how the object is implemented. That isn't always possible, but usually is. You're really only interested in the public (PUB) methods presented by the object to the outside world.
Particularly we are not able to get a time stamp to work properly with fullduplexserial, we want to have a deeper understanding of the code