Picaxe 20M and Serial Out pin double function as output ?

taux3

Member
Dear all,

Most probably this is for Technical but is it possible to use the serial out pin (for download) in the new comer 20M like it is used in 08M and 14M for output as well ?

Regards
Antony
________
drug testing kit
 
Last edited:

alexthefox

Senior Member
if you download the last version of the manual 1, you can find picaxe 20, with all info. but about your question, yes, pin0 = output
 

Technical

Technical Support
Staff member
Officially not, as output 0 is separate to the tx pin on the 20M. So 'high 0' is not the tx pin as it is on the 08M and 14M.

But Hippy will probably quickly tell you which register to poke for simple on/off control - in fact we will save him the hassle - it is bit0 of register 5!
 

hippy

Ex-Staff (retired)
Still plenty of fun to be had though ...

Can the on-chip SPI / I2C be made to work ? I'm not convinced it can, but it wouldn't be the first Microchip datasheet which says it won't work unless the hardware is setup the right way whereas it does.

Connecting a watch crystal to get accurate timing also looks possible ( it worked without messing up Serial In on the 08M ).

RA3, RA4 and RB7 look useful with Interrupt on Change and internal pull-ups.

I doubt there are going to be any shadow registers lurking around and if the firmware updates the TRIS registers frequently as I expect it will there isn't much scope for turning inputs into outputs and vice versa. One has to rely on enabling on-chip peripherals to override TRIS as they want them. Sometimes works, usually doesn't.

But the fun's in finding out :)
 

taux3

Member
How to?

Great, so how do I use the poke command to enable serial out as output ? Can it be done for Serial In as well to turn it into input?
Thanks
Antony
________
CL160
 
Last edited:

moxhamj

New Member
We are getting jealous down here in the Antipodes. None of our local suppliers have said they have the 20M yet. Or at least their websites haven't been updated. Are they being rushed south to us by courier pigeon as we speak?
 

hippy

Ex-Staff (retired)
@ taux3 : Untested, but from Technical's description and the pinout ...

Code:
Do
  Poke $05, %00000001      ' Set serial Out High (+V)
  Pause 500
  Poke $05, %00000000      ' Set serial Out Low (0V)
  Pause 500
Loop
A LED+R from Serial Out, pointy-end to 0V should flash at 1Hz.

Not sure about using the Serial In as a general purpose input. You could try this ...

Code:
SerRxd b0
Do
  Peek $05,b0
  If bit5 <> b1 Then
    If bit5 = 1 Then
      SerTxd( "HIGH - Connected",CR,LF )
    Else
      SerTxd( "LOW - Disconnected",CR,LF )
    End If
    b1 = bit5
  End If
Loop
You'll have to disconnect the download cable, take Serial In to +V with a wire to get past the SERRXD but then it should ( well, might ) track the connecting and disconnecting of the wire.

If it works, I even have an idea for doing this automatically :)
 

Technical

Technical Support
Staff member
Hippy, your first program will also corrupt some of the other outputs. You should really peek, set/clear the bit on the peeked value and then poke.

On second program, try the (undocumented) disconnect instead of serrxd.
 

hippy

Ex-Staff (retired)
Good point, I'll blame it on the sun coming up and frightening me :)

Code:
Do
  Peek $05, b7
  b7 = b7 | 1      ' Set serial Out High (+V)
  Poke $05, b7
  Pause 500
  Peek $05, b7
  b7 = b7 & $FE    ' Set serial Out Low  (0V)
  Poke $05, b7
  Pause 500
Loop
Undocumented DISCONNECT ... now why didn't I think of that :) :)
 

moxhamj

New Member
A bit like Ronald Reagan, who once said that he needed at least 8 hours of sleep every day. And as for the nights...
 

Macgyver

New Member
20M

Hi,

I found your code to use an extra o/p on the picaxe 20M. Im trying to use 9 outputs but cant seem to get the extra one to work, have you managed to get ti to work yourself, as you say its untested. Post was a while back now.

eg,
Poke $05, %00000001 ' Set serial Out High (+V)


Thanks
 

hippy

Ex-Staff (retired)
I don't have a 20M to test with but it should have worked, I'm sure Technical hinted it would.
 

manuka

Senior Member
I'm pondering 8x8 LED matrix driving with a PICAXE,which of course would normally use a 4017 decade counter or similar to provide the 8 +2 = 10 outputs normally needed. However a 5x7 matrix needs 7 + 2 = 9 outputs, which a "hacked" 20M may just be able to provide!

This Hippy/Tech. 9th output peek/poke has hence naturally teased, & I've confirmed it certainly works OK, with 8 normal 20M outputs also running. An LED from a 20M leg 19 to ground winks as expected, BUT - even without a dropper on a 4½ V supply - this is very faint & only detectable under dimmed room lighting. Output on this register may be too feeble as is, since code attempts to brighten it have been so far unsuccessful. Maybe an external hardware level boost will be needed-easy enough of course. Any code insights?
 
Last edited:

hax

New Member
Manuka, I don't follow what you mean. Do you mean that the serout pin does not have the same current capability of the other pins?

One would assume it would be 20ma just like the other pins. And you are using it with no resistor and it is still not bright enough?
 

manuka

Senior Member
Yes- regular 20-25mA source is what I'd have thought too! No dropper was used- just direct LED leg 19 to ground. The LED (green) glows brightly as code is downloaded from the editor PC,& works as normal in any other output. I've no time yet to take this further, but examining PIC16F677 data sheets is an obvious next step. Any one care to replicate this?
 

hippy

Ex-Staff (retired)
Don't have a 20M to try it with but the dimming could be down to PWM effect ... is the firmware clearing the Serial Out pin occassionally, is your program doing that ? Probably worth putting a scope on the pin.

There's no reason that pin shouldn't deliver the full ~20mA as all the others do, and I wouldn't expect download to work well if it didn't.
 
Top