PICAXE 20M2 serial out pin as regular output?

Three or four years ago, there was a thread about using the 20M serial output pin as a regular output (http://www.picaxeforum.co.uk/showthread.php?9170). At the time, there was some question as to whether the untested code (suggested by Hippy and Technical) would actually work. I've done some searching, but have been unable to locate any follow-ups, so I'm curious - has anyone been successful with this?

I have been trying to do the same thing with the serial out pin on a 20M2, but so far no luck. If I'm reading the PIC16F1829 data sheet correctly, the 20M2 serial out pin is bit 0 of portA (location 0x0C) on the PICmicro, so I adapted the code from the earlier 20M thread for the 20M2 as follows:

Code:
do
  peeksfr 0x0C, b0
  b0 = b0 | 0x01        ' set serial out High
  
  pokesfr 0x0C, b0
  wait 1
  
  peeksfr 0x0C, b0
  b0 = b0 & 0xFE      ' set serial out Low
  
  pokesfr 0x0C, b0
  wait 1
loop
Every two seconds, an LED attached to the serial out pin of the 20M2 blinks very briefly, so I think that I have the correct SFR address. However, the LED doesn't stay on during the one-second delay (the blink is so fast that it's just barely visible), so possibly the PICAXE firmware is doing something to reset the serial output pin? If that's the case, does anyone know of a way to stop it from doing so? I tried using "disconnect" but it didn't make any difference.

 

srnet

Senior Member
I just wrote a program Serout on a 08m2 to drive a LED, it works OK.

A sertxd command turns the LED off if its on, and it flashes during sertxd output and program downloads, but thats not a problem in my case.
 

Technical

Technical Support
Staff member
Think a bit more obvious!

high A.0
low A.0
serout A.0

are actually accepted as 'undocumented' commands on the 20M2.

They are not 'real' commands, as on the 20M2 this is not a 'general purpose i/o pin', so the compiler just outputs the appropriate pokesfr commands for you.
 
Thanks Technical - that certainly does the job!

Actually, I did think along those lines, but I made the mistake of starting with "symbol LED = A.0", which produced a syntax error, so I falsely assumed that A.0 was a no-no! Any chance of including the possibility of declaring a name for A.0?
 

Technical

Technical Support
Staff member
Not easily, because it's not a real command here and hence the compiler has to look for something, in this case the string 'A.0' exactly, to know to do a pokesfr instead. If we allow the symbol then the compiler can't stop it being used in other commands, e.g. like pulsout, and then people would complain that those other commands don't work on A.0 on the 20M2....
 
Last edited:
Top