Serout and SerIn Command on Picaxe 18M2 and 20M2

hal8000

Member
I need to send serial data from one micro-controller to another.
Both chips will be same type , either 18M2 or 20M2

Page 204 and 208 of manual 2 describes the serout and serin commands

SEROUT pin, baudmode, (data)

e.g. serout 7,N2400,(b1)

would transmit the data stored in variable b1 out over Pin7,
but over which port B or C?


Picaxe 14M, 18M, 20M have ports B and C.

For example to transmit or receive on Port C pin1 of a Picaxe 18M2
would the commands be:

serout C.1,N2400,(b1)

serin C.1,N2400,(b1)

Thanks in advance.
 

Goeytex

Senior Member
The manual is confusing as it uses examples that are for outdated Picaxe Chips where Port.Pin is not generally used. All of the current chips
should use the port.pin format for clarity. It seems you have sorted it out somewhat except ...

1. For readability/clarity at the default 4MHz clock you should probably use:

serout c.1,N2400_4,(b0)​

2. There are no parenthesis around the data to receive with serin. So that should be:

serin c.0,N2400_4,b0​

Goey
 

westaust55

Moderator
For the newer chips (M2 and X2) the port.pin nomenclature is recommended.

These IO designations are in fact pre defined constants where:
B.0 = 0
B .1 =1
:
B.7 =7
C.0=8
:
C.7=15, etc


NOTE also that the default clock speed for the M2 parts is 4 MHz.
Only the X2 parts have a default clock speed of 8 MHz.
 
Top