SERIN command in module AXE133Y? (Serial OLED display interface)

zorgloub

Member
Greetings to the Team of Specialists.
[ Post also open on the FR-Forum at http://www.picaxeforum.co.uk/showthread.php?29927-Commande-SERIN-dans-le-module-AXE133Y-(Serial-OLED-display-interface) ].

I look at the serial interface code for OLED display "AXE133Y" and I have a problem understanding with the Serin command as used here.

Source: http://www.picaxe.com/downloads/axe133y.bas.txt

Suppose that the MCU of the main system sends to the Serial interface the command [Serout C.4, Baud, (254, 192) '' Line Position.2, Col.1]

Therefore, 2 bytes (254 and 192) are sent here. The first to say "This is a command" and the second "to specify the code for this command: Position = Line2 / Column 1".

On the Serial Interface side, which receives this information, these two bytes must be processed.
Why does the Serial interface code use the [Serin RX, Baud, b1] command and not a [Serin RX, Baud, b1, b2] command to store the 2 bytes to be processed at one time ?:confused:

Also, is not the Serin command "blocking"?
That is, it would remain waiting for the bytes transmitted by serout (but which is only executed ONE time).

In my mind, the Serin command, placed at the beginning of the Main loop, as used here, will place the first byte in b1 but once this is done, the 2nd byte will be permanently lost and I do not see how the following Serin command , Placed lower in the conditional loop, will catch anything since there will be only ONE Serout transmitted and ALREADY read and that this Serout will have been sent only once and not renewed when This second Serin will arrive !?

Code:
main:

serin RX,baud,b1	; wait for the next byte <------------First SERIN ------------------- 1 byte !?

; NB keep character mode test as first item in this list to optimise speed

if b1 < 253 then		; CHARACTERS
  let pinsB = b1 		; output the data
  pulsout enable,1  	; pulse the enable pin to send data.
  goto main		; quickly loop back to top

else if b1 = 254 then	; CONTROL <--------------------------------
  low rs 	     		; change to command mode for next character
  serin RX,baud,b1	; wait for the command byte <------- Second SERIN --------------------------???????????????
  let pinsB = b1 		; output the data
  pulsout enable,1  	; pulse the enable pin to send data.
  high rs			; back to character mode
  goto main		; quickly loop back to top

else if b1 = 253 then	; MESSAGE(EEprom)
  serin RX,baud,b1	; wait for the next byte
  gosub msg		; do the 16 character message
  goto main		; back to top

else ; must be 255	; OUTPUT
  serin RX,baud,b1	; wait for the next byte
  let pinsC = b1 & %00000111 | %10000000
  ; output the data on C.0 to C.2, keep RS high
  goto main		; back to top

end if
Thank you for your help.
 
Last edited:

hippy

Technical Support
Staff member
In my mind, the Serin command, placed at the beginning of the Main loop, as used here, will place the first byte in b1 but once this is done, the 2nd byte will be permanently lost
The SEROUT (254, 192) command does not send out two bytes simultaneously but sequentially and there will be a time gap between them. Like catching two children who come down a slide one after the other, one person can catch the first then another can come in to catch the second.
 

zorgloub

Member
Hi Hippy,
Oh ok. I understand your image well.
But this kind of programming could only be used if the routine of processing between sending each byte is really very short.
What is the delay between receiving each byte in a command like [ Serout C.4, Baud, (254, 192) ] ?
Otherwise, I imagine that the [Serin RX, Baud, b1, b2] command would be possible and functional as well.
Exact ?
 
Last edited:

Technical

Technical Support
Staff member
You may be missing the fact that if the first byte is < 253 then ONLY one byte is needed. It is only 253 or 254 that needs two bytes.

Therefore if the first serin always waited for two bytes then it would not work correctly for all the normal characters (everything < 253)!
 

AllyCat

Senior Member
Hi,

Yes, as hippy has explained, the AXE 133 program code must execute between the received bytes. That might be quite a short time (i.e. between the STOP bit and the leading edge of the next START bit) because SERIN is itself executed by software. I have experimented with HSERIN (with an M2) but it's definitely not easy. :(

If inter-charcter timing is critical, then you might find my moderately recent thread of interest. One day, I might finish the complete coding. ;)

Cheers, Alan.
 

zorgloub

Member
Oh yes, indeed!
This observation is very judicious in cases where Byte1 <253. (so, only one byte needed)

- An idea of the time separating the reception of two bytes sent by a single command Serout sending two bytes?


Hi AllyCat,

I will read your study with great interest...

Thank.
 
Last edited:

Technical

Technical Support
Staff member
As a rough estimate a PICAXE serout command at N2400 has a gap about the length of an extra stop bit between the bytes sent - so the bytes are not back to back.


On a serin command the 10th bit received (the stop bit) is sampled about half way along the bit and then PICAXE gets ready for the next byte (or next command).


So in this case (PICAXE serout to AXE133 PICAXE serin) the receiving chip has


1/2 stop bit + gap between bytes = 1.5 bits of time to do 'other stuff' before the start bit of the next byte is received. This is enough time to allow the AXE133 code to work reliably with two serins.
 
Top