20X2 interrupts

Vroom

Member
I have a 20x2 (B.0) using there commands hintsetup %00000010 and sleep 10 for input trigger B.0 with using resistor 100K and capacitor 0.1uf for pause quickly (because need clear 0 to down first after started 1) from three press switches input C.0-2 with three separate diode each to B.0 with use resistor and capacitor. Its working, but not surely sometime problem what did not work interrupt when press so wait clear sleep until run out of sleep 10sec then finally any high input C.0-2, example my code every 23sec for go to check and then back to main, if code is right about HintSetup and sleep 10 , because save power for every 23sec


main:
HintSetup %00000010
sleep 10
if pinC.0=1 then first
if pinC.1=1 then second
if pinC.2=1 then third
goto check

check:

first:

second:

third:
 

inglewoodpete

Senior Member
Hi vroom8, I'm really struggling to understand your problem. There are so many words and no punctuation which I am used to.

Is English your first language? If not English, please post your question again in your usual language. Forum members will try the understand what your question means.

1. Please post your whole code (using <code> </code> delimiters).

2. Please post your circuit diagram.

3. Please tell us the purpose of your project.

This will help members understand the problem.

Peter
 
Last edited:

Jamster

Senior Member
English: As Ingle... said we/you can always use google translate if your english isn't brilliant.

Suomi: Kuten Ingle ... sanoi, että meidän / voit aina käyttää Google kääntää, jos englanti ei ole loistava.

Deutsch: Als Ingle ... gesagt, wir / Sie können immer Google Translate, wenn Ihr Englisch ist nicht brillant.

Français: Comme Ingle ... dit que nous / vous pouvez toujours utiliser google translate si votre anglais n'est pas brillant.

Cymraeg: Fel Ingle ... Dywedodd yr ydym / gallwch chi bob amser yn defnyddio cyfieithu google os yw eich Saesneg yn peidio wych.

Have I hit yet??
 

kevrus

New Member
I suspect you haven't posted the full code nd s others ave mentioned, its difficult to understand your problem. My take on it is initial observations suggest you need to issue a 'setintflags' command and have a sub-routine labelled 'interrupt', which will also need to reset the flags and re-issue the interrupt command before 'return'.

untested but maybe something like this...
Code:
#picaxe 20x2                          'this tells the P.E. whch chip is bieng used

main:
HintSetup %00000010		       'sets the interrupt pin
setintflags %00000010,%00000010	       'sets the flags condition for the interrupt

	do 
	sleep 10
	loop	


interrupt:
b0=pinsC & %00000111 / 2		'masks all but the first 3 pins and shifts one place to 
                              	        'the right for correct routine selection
on b0 gosub first,second,third	        'and this selects the correct routine
		
	flags=0			        'reset the flags
	setintflags %00000010,%00000010 'and re=issue the interrupt command
	return
first:
        'de-bounce the switch
	'DO SOMETHING
	return
second:
        'de-bounce the switch
 	'DO SOMETHING
	return
third:
        'de-bounce the switch
	'DO SOMETHING
	return
 

Vroom

Member
I suspect you haven't posted the full code nd s others ave mentioned, its difficult to understand your problem. My take on it is initial observations suggest you need to issue a 'setintflags' command and have a sub-routine labelled 'interrupt', which will also need to reset the flags and re-issue the interrupt command before 'return'.

untested but maybe something like this...
Code:
#picaxe 20x2                          'this tells the P.E. whch chip is bieng used

main:
HintSetup %00000010		       'sets the interrupt pin
setintflags %00000010,%00000010	       'sets the flags condition for the interrupt

	do 
	sleep 10
	loop	


interrupt:
b0=pinsC & %00000111 / 2		'masks all but the first 3 pins and shifts one place to 
                              	        'the right for correct routine selection
on b0 gosub first,second,third	        'and this selects the correct routine
		
	flags=0			        'reset the flags
	setintflags %00000010,%00000010 'and re=issue the interrupt command
	return
first:
        'de-bounce the switch
	'DO SOMETHING
	return
second:
        'de-bounce the switch
 	'DO SOMETHING
	return
third:
        'de-bounce the switch
	'DO SOMETHING
	return



I got your code, thanks. I put code and changed, when first start then main2 ready sleep, and then press Hint then wake up while press any first, second, and three do something well, now back second time go sleep again so cant do interrupt anymore like freeze, turn off the power then startup working once, and cant do second time, maybe something is not right with code

wait 2

serout 1,T9600, (254,12)
'pause 30
'serout 1,T9600, (254,1," Welcome")
'pause 30
serout 1,T9600, (254,194,"World")
wait 4

main:
for b1= 1 to 200
if pinC.2=1 then first
if pinC.1=1 then second
if pinC.0=1 then three
pause 25
next b1

main2:
HintSetup %00000010 'sets the interrupt pin
setintflags %00000010,%00000010 'sets the flags condition for the interrupt

do
sleep 10
loop


interrupt:
b0=pinsC & %00000111 / 2 'masks all but the first 3 pins and shifts one place to
'the right for correct routine selection
on b0 gosub first,second,three 'and this selects the correct routine

flags=0 'reset the flags
setintflags %00000010,%00000010 'and re=issue the interrupt command
return


first:
'de-bounce the switch
'DO SOMETHING
goto main

second:
'de-bounce the switch
'DO SOMETHING
goto main

three:
'de-bounce the switch
'DO SOMETHING
goto main
 
Top