commented code for the full duplex serial communication protocol!
gandolf
Posts: 3
Gentlemen i am working on this application where in i have to connect a bluetooth module to the propeller. I was trying to understand how the serial protocol works and the commenting in the code posted in the website is insufficient .
I would appreciate it if anyone could help me out by providing me a completely commented code for the above mentioned protocol.........
I would appreciate it if anyone could help me out by providing me a completely commented code for the above mentioned protocol.........
Comments
The Simple_Serial object from the Propeller Object Exchange is probably the simplest serial interface you will find for the Propeller. It's all written in Spin and can handle roughly 19.2KBaud. You can easily add receive buffering to it and run a copy in a separate cog for buffered reception. There are several other serial drivers that use assembly to provide buffering, higher Bauds, and multiple serial ports in one cog. Since the Spin interfaces for all of these are very similar, they can generally be substituted for each other with minor changes if any.
You are not likely to get a "completely commented code". Most of the experts who respond here are volunteers and are much more likely to answer well asked questions than to spend time and effort producing a "finished document". There's nothing wrong in asking ... sometimes volunteers become inspired and take on a mostly thankless time-consuming task, but you will do much better following the above suggestion.
1. in the first method
PUB start(rxpin,txpin,mode, baudrate)
stop
longfill(@rx_head,0,4).........................what exactly is @rx_head here(address of what)?
we reserve 4 long memory locations from the starting address @rx_head, what are we reserving this for?
2. In the second method
Pub Stop
if cog
(cogstop~ -1)
longfill(@rx_head,0,9)..........here when freeing a cog we set 9 long memory location staring from @rx_head to 0, why 9 long memory locations staring from @rx_head?
what do long memory locations rx_head,rx_tail, tx_head, tx_tail, rxtx_mode contain?
2) The LONGFILL in the stop method just reinitializes the 9 long word variables that are passed to the assembly routine. The assembly routine is stopped at this point, so it's not vital to reinitialize these, but it's cleaner to do so.
rx_head: output index of the current receive buffer (data gets removed from the buffer at the output index position)
rx_tail: input index of the current receive buffer (new data gets put in the buffer at the input index position)
tx_head: output index of the current transmit buffer (data gets removed from the buffer at the output index position)
tx_tail: input index of the current transmit buffer (new data gets put in the buffer at the input index position)
rx_pin: a copy of the rxpin parameter to the start method
tx_pin: a copy of the txpin parameter to the start method
bit_ticks: CLKFREQ / baudrate, calculated from the baudrate parameter to the start method
rxtx_mode: a copy of the mode parameter to the start method
buffer_ptr: the address of the receive buffer (the transmit buffer follows the receive buffer)
If you haven't already found it,
http://forums.parallax.com/showthread.php?p=562370
this search tool will help you dig through the forum easier.
Post Edited (TChapman) : 4/8/2009 6:30:14 AM GMT