SETINT on a Picaxe 08M2

FIREMANJIM

New Member
The Picaxe Manual #2 is not real clear as to what pins a SETINT can be done on a 08M2 chip.....So I will ask you PROs....What pins on the Picaxe 08M2 chip can I do a SETINT on??? Thanks in advance for all your help....Jim
 

inglewoodpete

Senior Member
Interrupts can be used on all pins that can be configured as an input (C.1 to C.4). Refer to "Variables - Special function", page 17 of Manual 2 for input pins.

I have never tried to use an interrupt on the SerIn pin, when configured as a digital input. There may be an expert around who has tested that pin, otherwise, you'll have to test it yourself....
 

FIREMANJIM

New Member
I want to set a Interrupt on C.3 when it goes high. I only want to monitor C.3 so I think the correct binary code would be SETINT %001000, %001000 Is This Correct???
 

inglewoodpete

Senior Member
That's correct. The second byte after the SetInt command says "only monitor input 3 (C.3) for interrupts". The first byte indicates that a high condition (1) on pin C.3 will cause the interrupt.

Have you written code for your interrupt routine?
 

FIREMANJIM

New Member
Here is the code Pete:
Code:
'Remote Slave Controller 
'Picaxe 08m2 chip

Symbol CDSPwr = c.0
Symbol CDSRead = c.1
Symbol SlavePwr = c.2
Symbol PTPwr = c.4
Symbol PTInput = PINC.3
Symbol SerialIn = PINC.5
'set bit variables
Symbol DayStatus = bit0
Symbol SlaveOn = bit1
Symbol PTPwrOn = bit2
'set byte variables
Symbol DayLevel = b2
Symbol DaySetting = b3
Symbol NightSetting = b4
Symbol Counter1 = b5
Symbol Counter2 = b6
'set word variables
Symbol CheckCDSTimer = w3
Symbol CheckCDSTime = w4
Symbol SlaveRefreshTimer = w5
Symbol SlaveRefreshTime = w6

disablebod

Low SlavePwr
Low CDSPwr
Low PTPwr
' set input pins as inputs
Input c.3
Input c.5
' set default variable settings
DayStatus = 1
SlaveOn = 0
PTPwrOn = 0
DaySetting = 128
NightSetting = 117 
CheckCDSTime = 6660
SlaveRefreshTime = 6660	'1 second = 111
nap 5 

High SlavePwr
SlaveOn = 1
Pause 30000
Low SlavePwr
SlaveOn = 0
Nap 3
High       CDSPwr                    ' apply power to CDS sensor
Nap 5     ' allow power to settle
ReadADC                CDSRead, DayLevel
Low CDSPwr
If DayLevel <= NightSetting Then
     	DayStatus = 0
	High PTPwr
	PTPwrOn = 1
	Pause 500
EndIf
If DayLevel >= DaySetting Then
	DayStatus = 1
	Pause 500
EndIf
Pause 1000

SetFreq m4
SETINT %001000,%001000


MainProgramLoop:
If DayStatus = 1 Then
	Sleep 130
	High       CDSPwr                    ' apply power to CDS sensor
	Nap 5     ' allow power to settle
	ReadADC                CDSRead, DayLevel
	Low CDSPwr
	If DayLevel >= DaySetting Then
		DayStatus = 1
	EndIf	
	If DayLevel <= NightSetting Then
     		DayStatus = 0
		If SlaveOn = 0 Then
			High SlavePwr
			SlaveOn = 1
			Pause 25000
			Low SlavePwr
			SlaveOn = 0
			Pause 500
		EndIf
		If PTPwrOn = 0 Then
			High PTPwr
			PTPwrOn = 1
			Pause 500
		EndIf
	EndIf

EndIf

If DayStatus = 0 Then
	
	SlaveRefreshTimer = SlaveRefreshTimer + 1
	If SlaveRefreshTimer >= SlaveRefreshTime Then
		Counter1 = Counter1 + 1
		SlaveRefreshTimer = 0
	EndIf
	If Counter1 >= 10 Then
		High SlavePwr
		SlaveOn = 1
		Pause 12000
		Low SlavePwr
		SlaveOn = 0
		SlaveRefreshTimer = 0
		Counter1 = 0
	EndIf
	
	CheckCDSTimer = CheckCDSTimer + 1
	If CheckCDSTimer >= CheckCDSTime Then
		Counter2 = Counter2 + 1
		CheckCDSTimer = 0
	EndIF
	If Counter2 >= 10 Then
		High       CDSPwr                    ' apply power to CDS sensor
		Nap 5     ' allow power to settle
		ReadADC                CDSRead, DayLevel
		Low CDSPwr
		If DayLevel <= NightSetting Then
     			DayStatus = 0
			Counter2 = 0
		EndIf
		If DayLevel >= DaySetting Then
			DayStatus = 1
			Counter2 = 0
			If SlaveOn = 1 Then
				Low SlavePwr
				SlaveOn = 0
				Pause 500
			EndIf
			If PTPwrOn = 1 Then
				Low PTPwr
				PTPwrOn = 0
				Pause 500
			EndIf
		EndIf
	EndIf
EndIf
GoTo MainProgramLoop

Interrupt:
High SlavePwr
SlaveOn = 1
Pause 25000
Low SlavePwr
SlaveOn = 0
Counter1 = 0
SlaveRefreshTimer = 0
SETINT %001000,%001000
Return
 

westaust55

Moderator
Beware that word variable w3 occupies the same memory as byte variables b6 and b7.
There is a conflict in your Symbol statements.
 
Top