hippy
Ex-Staff (retired)
The following code for 14M2, 18M2, 18M2+ and 20M2 allows a differential serial signal to be generated, similar to RS422 using 0V/+V signalling. This may be useful for example when wanting to drive DMX-512 and don't have any proper RS422/RS485 line divers to hand.
The code uses the DSM on-chip hardware to create an inverse of the HSEROUT signal. Non-M2's don't have DSM hardware and 08M2 has HSEROUT and DSM output on the same pin so it doesn't work for those.
Same code for all but output pins are different -
14M2
TX+ Output on B.0, Idle High
TX- Output on C.1, Idle Low
18M2 / 18M2+
TX+ Output on B.5, Idle High
TX- Output on B.3, Idle Low
20M2
TX+ Output on C.0, Idle High
TX- Output on C.4, Idle Low
Output looks like ...
The code uses the DSM on-chip hardware to create an inverse of the HSEROUT signal. Non-M2's don't have DSM hardware and 08M2 has HSEROUT and DSM output on the same pin so it doesn't work for those.
Same code for all but output pins are different -
14M2
TX+ Output on B.0, Idle High
TX- Output on C.1, Idle Low
18M2 / 18M2+
TX+ Output on B.5, Idle High
TX- Output on B.3, Idle Low
20M2
TX+ Output on C.0, Idle High
TX- Output on C.4, Idle Low
Code:
PokeSfr $FC, %11000000 ; SFR $39C MDCON
PokeSfr $FD, %00001010 ; SFR $39D MDSRC
PokeSfr $FE, %01000000 ; SFR $39E MDCARL
PokeSfr $FF, %00000000 ; SFR $39F MDCARH
HSerSetup B9600_4, %000
Do
HSerOut 0, ( "U" )
Pause 100
Loop
Code:
_____ _ _ _ _ _____
TX+ |_| |_| |_| |_| |_|
_ _ _ _ _
TX- _____| |_| |_| |_| |_| |_____
S 0 1 2 3 4 5 6 7 P