Using 08M2 Serial Input Pin as Digital Input

erco

Senior Member
I need to squeeze one more input for my 08M2 project, so I want to use the serial input programming pin (C.5) to attach a microswitch for occasional use. According to manual 2, the internal pullup resistors are only available for C.0 to C.4 so I'll need to add an external resistor. My previous attempt to use an IR receiver on that same pin interfered with programming the chip. That receiver was connected directly to the pin. I should have tried adding a switch to disconnect it from the pin for programming. Next time.

It seems like adding a digital switch should be possible and should not require a disconnect switch if done properly. My question for the experts: is it better to use a pullup or pulldown resistor, and what value, ~100K?
 

erco

Senior Member
I feel a bit silly answering my own question so quickly, but I squeezed my hands into my tiny product enclosure and did some tests. Results shared here for future generations.

A 100K pulldown resistor worked perfectly, program downloaded fine every time.

A 100K pullup resistor failed, I got a memory verification error every time during program download.
 

erco

Senior Member
After installing the 100K pulldown resistor and N.O. switch to +5V, I found that I had to use the DISCONNECT command or the 08M2 would reset each time the switch was closed. After that, it's a simple matter to check switch status with pinc.5 .
 

AllyCat

Senior Member
Hi,

According to manual 2, the internal pullup resistors are only available for C.0 to C.4 so I'll need to add an external resistor.
The manual isn't entirely correct, because the PE won't set a pullup on C.0 either:
Code:
#picaxe 08m2
symbol wpua   = $8C		; Weak PullUps on M2s
pullup 32
;Error: C.5 cannot use pullup, as that places chip in permanent new download mode!
pullup 1
;Error: C.0 pin is output only, so cannot have pullup!
pokesfr wpua,63     ; Pullup ALL input pins
But the Weak Pullups on both pins C.0 and C.5 can be (usefully) enabled if required. C.0 can be set as the DAC output which has a high output impedance and can be read with the readdac command. So I have found a few (rare) occasions when enabling that WPU can be useful.

Certainly, enabling the WPU on C.5 can be useful (after a disconnect), but "reliable" operation (i.e. with the pullup resistance value towards its upper specification limit) it may be necessary to increase the 22k (or maybe the 10k) programming resistors to perhaps 100k (which IMHO under all normal operation conditions should be fine).

Personally, I nearly always use the pokesfr version anyway, because the same (mask) values as the 08M2 also apply to the corresponding Leg positions (e.g. the "input only" pins) on the 14M2 and 20M2. Note that they are all on the base PIC Port A.

Cheers, Alan.
 

erco

Senior Member
Thanks for the help, fellas. Great workarounds, Alan. I see now that my 100K pulldown resistor shouldn't be required since it's in parallel with 32K of download circuit resistors.

I've mainly used the 20M2 but lately I'm enjoying learning about the 08M2 and stretching its usefulness while learning about its idiosyncrasies, such as TUNE only working on pin 2.
 
Top