Hi, I'm confused about FullDuplexSerial code...
hans90
Posts: 29
in Propeller 1
Hi everyone, I am trying to understand the FullDuplexSerial Assembly code and while I am studying it I am becoming confused at one point. Please disregard that I am asking a stupid question: what is the VAR tx_buffer[64] & rx_buffer[64] declaration? Is this a buffer area in Hub's Ram shared by Cog's Ram between Spin and Assembly to store what is being transmitted and received by Prop chip? What is VAR Long rx_head declaration for? For example, tx_buffer[rx_head], why rx_head is the number of tx_buffer array elements? Isn't rx_head a start bit in UART?
Please some one help me out!
[img][/img]
Please some one help me out!
[img][/img]
Comments
Start and stop bits of each byte transmitted, or received on the line is a different thing.
The _head and _tail variables are pointers into those buffers. For the receive buffer, they keep track of where the next unread character is stored and where the last character received is stored. For the transmit buffer, they keep track of where the last character from the user's program is stored and where the next character to be transmitted is stored.
The buffers operate in circular fashion. Once a character is stored or retrieved from the end of the buffer, the appropriate pointer cycles back to the beginning of the buffer. The repeat until statement you've shown waits until there's room in the transmit buffer for a new character from the user's program.
-PHil
Thanks very much for the reply on ring buffer!
My question is what does the program use to print things? I tried to understand the code where it prints things. It seems to me it uses method PUB tx(txbyte) to print but I think tx_buffer[tx_head] := txbyte only moves strings into the ring buffer without printing it. In the following assembly code I don't really find a specific instruction that prints things. Did I miss anything in assembly that prints? I'm confused...
-Phil
It is not necessary to understand the pasm code running in the other cog. FDX will work reliably at least up to 115,200 baud.