C.7 high Resets 20x2

andrew_qld

Senior Member
Hi,
I am building a circuit where a Picaxe 20x2 sends serial using the sertxd command when one of 16 inputs go low.

Everything works, but the chip resets when input C.7 goes high again.

Pins C.0 to C.7 and B.0 to B.7 are held high by 4k7 resistors. A switch pulls these pins to earth via a 1k resistor.

I have tried using let dirsc = %00000000 and several other ideas including changing components. The circuit is on breadboard prior to making a PCB and the 10k & 22k programming resistors are present. The supply is a regulated 5V. The 20X2 chip is version C.1 and the programmer is version 5.2.11

As I said, it sends serial normall when C.7 is pulled low, but as soon as the input dissapears and it goes high, the chip resets and sends the usual serial preamble on the programming pin when it starts up.

Any ideas?

Cheers,
Andrew

Here is the code:

Code:
main:
if pinc.0 = 0 then pause 100 endif
if pinc.0 = 0 then sertxd ("0") endif
if pinc.1 = 0 then pause 100 endif
if pinc.1 = 0 then sertxd ("1") endif
if pinc.2 = 0 then pause 100 endif
if pinc.2 = 0 then sertxd ("2") endif
if pinc.3 = 0 then pause 100 endif
if pinc.3 = 0 then sertxd ("3") endif
if pinc.4 = 0 then pause 100 endif
if pinc.4 = 0 then sertxd ("4") endif
if pinc.5 = 0 then pause 100 endif
if pinc.5 = 0 then sertxd ("5") endif
if pinc.6 = 0 then pause 100 endif
if pinc.6 = 0 then sertxd ("6") endif
if pinc.7 = 0 then pause 100 endif
if pinc.7 = 0 then sertxd ("7") endif
if pinb.0 = 0 then pause 100 endif
if pinb.0 = 0 then sertxd ("8") endif
if pinb.1 = 0 then pause 100 endif
if pinb.1 = 0 then sertxd ("9") endif
if pinb.2 = 0 then pause 100 endif
if pinb.2 = 0 then sertxd ("10") endif
if pinb.3 = 0 then pause 100 endif
if pinb.3 = 0 then sertxd ("11") endif
if pinb.4 = 0 then pause 100 endif
if pinb.4 = 0 then sertxd ("12") endif
if pinb.5 = 0 then pause 100 endif
if pinb.5 = 0 then sertxd ("13") endif
if pinb.6 = 0 then pause 100 endif
if pinb.6 = 0 then sertxd ("14") endif
if pinb.7 = 0 then pause 100 endif
if pinb.7 = 0 then sertxd ("15") endif
goto main
 

lanternfish

Senior Member
Just simulated your program with no probs so suggests hardware problem.
Also rewrote:

Code:
init:
dirsC = %00000000
dirsB = %00000000

sertxd ("initialising")

main:
if pinc.0 = 0 then sertxd ("0 ") endif
if pinc.1 = 0 then sertxd ("1 ") endif
if pinc.2 = 0 then sertxd ("2 ") endif
if pinc.3 = 0 then sertxd ("3 ") endif
if pinc.4 = 0 then sertxd ("4 ") endif
if pinc.5 = 0 then sertxd ("5 ") endif
if pinc.6 = 0 then sertxd ("6 ") endif
if pinc.7 = 0 then sertxd ("7 ") endif
if pinb.0 = 0 then sertxd ("8 ") endif
if pinb.1 = 0 then sertxd ("9 ") endif
if pinb.2 = 0 then sertxd ("10 ") endif
if pinb.3 = 0 then sertxd ("11 ") endif
if pinb.4 = 0 then sertxd ("12 ") endif
if pinb.5 = 0 then sertxd ("13 ") endif
if pinb.6 = 0 then sertxd ("14 ") endif
if pinb.7 = 0 then sertxd ("15 ") endif
pause 100
goto main
The line sertxd ("initialising") will be transmitted initially and then every time the 20X2 resets.

Let us know how you get on
 

andrew_qld

Senior Member
Sorted out now

OK looks like the problem is that I'm an idot.

The problem was a breadboard jumper that wasn't quite making contact with the 10k resistor on the Serial in pin.

lanternfish, you were on the right track.

Interestingly a large value cap on C.7 would fix (10uF). Probably by smothing the switching spikes.

We live and learn...
 

andrew_qld

Senior Member
Re-wrote code as well

@ lanternfish- this was my final code- very similar to yours. Debounces the pins and won't reset the input until the pin goes high again.

I had a surface mount PCB layed out but alway check it on breadboard first.

Code:
main:
if pinsc = %11111111 and pinsb = %11111111 then goto main
if pinc.0 = 0 then sertxd ("*0OR01P08",13,10) endif
if pinc.1 = 0 then sertxd ("*0OR02P08",13,10) endif
if pinc.2 = 0 then sertxd ("*0OR03P08",13,10) endif
if pinc.3 = 0 then sertxd ("*0OR04P08",13,10) endif
if pinc.4 = 0 then sertxd ("*0OR05P08",13,10) endif
if pinc.5 = 0 then sertxd ("*0OR06P08",13,10) endif
if pinc.6 = 0 then sertxd ("*0OR07P08",13,10) endif
if pinc.7 = 0 then sertxd ("*0OR08P08",13,10) endif
if pinb.0 = 0 then sertxd ("*0OR09P08",13,10) endif
if pinb.1 = 0 then sertxd ("*0OR10P08",13,10) endif
if pinb.2 = 0 then sertxd ("*0OR11P08",13,10) endif
if pinb.3 = 0 then sertxd ("*0OR12P08",13,10) endif
if pinb.4 = 0 then sertxd ("*0OR13P08",13,10) endif
if pinb.5 = 0 then sertxd ("*0OR14P08",13,10) endif
if pinb.6 = 0 then sertxd ("*0OR15P08",13,10) endif
if pinb.7 = 0 then sertxd ("*0OR16P08",13,10) endif
do
pause 200
if pinsc = %11111111 and pinsb = %11111111 then exit
loop
goto main
 

westaust55

Moderator
@Andrew,

Not solving your immediate problem (sorry), but seeing so many IF. . . THEN statements,
if you will only every have one input pulled low at any time then something like the following might work for you.

Code:
Main:
  b0 = pinsc
  b1 = pinsb
  b2 = NCD w0
  IF b2>0 THEN
    PAUSE 100
    SERTXD (#b2)
  ENDIF
  GOTO Main
Would need some variant if you need to check for possible multiple inputs low but could be done in a loop
 
Top