28X1 coding issue

magnustullock

New Member
Hi folks,
I am using a 28x1 chip. Can anyone tell me how to check for input on A.0 - A.3? I have tried searching and all of the answers come up with a check error. I have outputs working by accessing B.0 - B.7 and portc 0 - portc 6 (portc 7 is an interrupt pin - unless this can also be accomplished by an A port?) but checking for input on porta pin 0 seems to give me errors.

Thanks
Magnus
 

magnustullock

New Member
Sorry, I actually thought it would be too much of a newbe question for anyone to care about! lol

the code turned out to be:

Code:
if PORTA pin0 = 1 then
does the trick.

Still dont know about getting an interrupt on the A pins though. What I am doing is an LED chaser sequence which performs one set of light actions on power up, another for running, and another for power down:

Code:
symbol timeout = 0
symbol StepDelay = 0
Symbol WhatCase = b2
Symbol PowerUp = b3
Symbol PowerDown = b4

PowerUp = 1
PowerDown = 0

let dirsC = %0111111
low B.0, B.1, B.2, B.3, B.4, B.5, B.6, B.7
low portc 0, 1, 2, 3, 4, 5, 6
			
main:

	if PORTA pin0 = 1 then
		if PowerUp = 1 then
			gosub startUp 
			powerUp = 0
			PowerDown = 1
			setint %10000000,%10000000	
		endif
		
		gosub running 
	endif
	
	if PORTA pin1 = 1 then
		if PowerDown = 1 then
			setint %00000000,%00000000
			gosub shutdown 
			powerUp = 1
			PowerDown = 0							
		endif
	endif
	
goto main


startUp:
	high portc 6
	high portc 5

	pause StepDelay

	low portc 6
	high portc 4
	
	pause StepDelay
	
	low portc 5
	high portc 3
	
	pause timeout
	
	low portc 4
	high portc 2
	
	pause timeout
	
	low portc 3
	high portc 1
	
	pause timeout
	
	low portc 2
	high portc 0
		high portc 6
		high portc 5 
				
	pause timeout
	
	low portc 1
	high B.7
		low portc 6
		high portc 4
	
	pause timeout
	
	low portc 0
	high B.6
		low portc 5
		high portc 3
	
	pause timeout
	
	low B.7
	high B.5
		low portc 4
		high portc 2	
	
	pause timeout
	
	low B.6
	high B.4
		low portc 3
		high portc 1	
	
	pause timeout
	
	low B.5
	high B.3
		low portc 2
		high portc 0
			high portc 6
			high portc 5 			
	
	pause timeout
	
	low B.4
	high B.2
		low portc 1
		high B.7
			low portc 6
			high portc 4	
						
	
	pause timeout
	
	low B.3
	high B.1
		low portc 0
		high B.6
			low portc 5
			high portc 3			
	
	pause timeout
	
	low B.2
	high B.0
		low B.7
		high B.5
			low portc 4
			high portc 2	
		low B.6
		high B.4
			low portc 3
			high portc 1		
		low B.5
		high B.3
			low portc 2
			high portc 0
				high portc 6
				high portc 5
		low B.4
		high B.2			
			low portc 1
			high b.7
				low portc 6
				high portc 4				
			low portc 0
			high b.6
				low portc 5
				high portc 3	
			low B.7
			high B.5
				low portc 4
				high portc 2
			low B.6
			high B.4
				low portc 3
				high portc 1										
				low portc 2
				high portc 0
					high portc 6
					high portc 5	
				low portc 1
				high B.7
					low portc 6
					high portc 4	
				low portc 0
				high B.6
					low portc 5
					high portc 3
					low portc 4
					high portc 2
					low portc 3
					high portc 1										
					low portc 2
					high portc 0
						high portc 6
						high portc 5
						low portc 6
						high portc 4
						low portc 5
						high portc 3
						low portc 4
						high portc 2	
							high portc 6
							high portc 5
							low portc 6
							high portc 4
							low portc 5
							high portc 3
								high portc 6
								high portc 5
								low portc 6
								high portc 4
									high portc 6
									high portc 5

	gosub highlow					

							
	pause timeout
	
return

shutdown:
	gosub lowhigh
	gosub highlow
return

running:
	gosub lowhigh
	gosub highlow
return

lowhigh:
	high B.0
	pause timeout
	high B.1
	pause timeout
	high B.2
	pause timeout
	high B.3
	pause timeout
	high B.4
	pause timeout
	high B.5
	pause timeout
	high B.6
	pause timeout
	high B.7
	pause timeout
	high portc 0
	pause timeout
	high portc 1
	pause timeout
	high portc 2
	pause timeout
	high portc 3
	pause timeout
	high portc 4
	pause timeout
	high portc 5
	pause timeout
	high portc 6
	pause timeout
return	

highlow:
	low portc 6
	pause timeout
	low portc 5
	pause timeout
	low portc 4
	pause timeout
	low portc 3
	pause timeout
	low portc 2
	pause timeout
	low portc 1
	pause timeout
	low portc 0
	pause timeout
	low B.7
	pause timeout
	low B.6
	pause timeout
	low B.5
	pause timeout
	low B.4
	pause timeout
	low B.3
	pause timeout
	low B.2
	pause timeout
	low B.1
	pause timeout
	low B.0
	pause timeout
return

interrupt:

high B.7
high B.0
high portc 6


high B.1
high portc 5

low B.1
low portc 5

high B.2
high portc 4

low B.2
low portc 4

high B.3
high portc 3

low B.3
low portc 3

high B.4
high portc 2

low B.4
low portc 2

high B.5
high portc 1

low B.5
low portc 1

high B.6
high portc 0

low B.6
low portc 0

high B.6
high portc 0

low B.6
low portc 0

high B.5
high portc 1

low B.5
low portc 1

high B.4
high portc 2

low B.4
low portc 2

high B.3
high portc 3

low B.3
low portc 3

high B.2
high portc 4

low B.2
low portc 4

high B.1
high portc 5

low B.1
low portc 5

if pinC.7 = 1 then interrupt ; loop here until the interrupt cleared
setint %10000000,%10000000 ; re-activate interrupt

return

#no_data    'reduce download time
I am sure there is more efficient ways of doing this, but this is my first attempt :)
 

inglewoodpete

Senior Member
Nowadays, we're spoiled for choice with the M2 and X2 series of chips.

The primary purpose of the 28x1's Port A was (the only) ADC inputs. As magnus discovered the only* way to read the logic level on the Port A is via the "If PortA pinX" statement.

*It may be possible to read Port A via SFR $05 (Eg. Peek $05, bX) but it is not something I have tried on a PICAXE. I'll leave others to comment on using the SFRs.
 

magnustullock

New Member
actually now I have downloaded it to the chip, it doesnt work.

if porta pin0 = 1 then
.
.
endif

if porta pin1 = 1 then
.
.
endif

this seems to be that porta pins retain some form of memory. Even if I flip the switch to take the signal away from pin0 the sequence continues to run anyway. any ideas?

thanks
 

magnustullock

New Member
Do you have a pull up (or down) resistor on the input as well as a switch?
I do. What makes it stranger, it seems to retain the signal even after turning the battery off and on! I turn the battery off then on and the sequence for that input pin happens without being pressed!

would a mistake on the pull down resistor cause this? if so I will go and check the connections there.

thanks
 

inglewoodpete

Senior Member
I think it is time for you to post 1. A circuit diagram of how you have wired your PICAXE input and 2. A close-up photo or two of your set up will help give us (and you) a few clues as to what is going wrong. Unless damaged, the Port A pins DO work well as digital inputs.
 
Top