View previous topic :: View next topic |
Author |
Message |
Jogi864
Joined: 05 Oct 2010 Posts: 2
|
Posted: Fri Dec 12, 2014 10:01 pm Post subject: Return in ISR -- AVR Reset ?? |
|
|
Hi Bascom Users,
I have a question. I have connect a 12er Keypad on Port A on a Atmel 1284P.
All connections goes over a Resistor 470R on every Line.
Row 1= A1, Row2 = A2.... Col1=A5, Col2= A6...and so on.
i use PCINT to for Interrupt.
Here is the Code what is not working. It seems that the Avr do a Reset when he comes to the "Return" who is in the If.. then.. circle in the ISR (ok sorry for my bad English)
Code: |
$regfile = "m1284pdef.dat"
$crystal = 14745600
$hwstack = 128
$swstack = 128
$framesize = 128
$baud = 9600
Dim Ma As Byte
Dim Z As Byte
Ddra = &B11110000
Porta = &B00001111
Print " ready..."
Enable Pcint0
Pcmsk0 = &B00001111
On Pcint0 Taste
Enable Interrupts
Ma = 1
Open "com1:" For Binary As #1
Do
Incr Z
Print #1 , "Zähler:" ; Z
Print #1 , "Loop"
Print #1 , "Ma: " ; Ma
Wait 3
Loop
Taste:
Print #1 , "Jetzt in ISR"
If Ma = 1 Then
Ma = 2
Pcifr.0 = 1
Return
End If
Print #1 , "Jetzt ganz in ISR"
Pcifr.0 = 1
Ma = 1
Return
|
I dont know why this is not working????
but this works:
Code: |
$regfile = "m1284pdef.dat"
$crystal = 14745600
$hwstack = 128
$swstack = 128
$framesize = 128
$baud = 9600
Dim Ma As Byte
Dim Z As Byte
Ddra = &B11110000
Porta = &B00001111
Print " ready..."
Enable Pcint0
Pcmsk0 = &B00001111
On Pcint0 Taste
Enable Interrupts
Ma = 1
Open "com1:" For Binary As #1
Do
Incr Z
Print #1 , "Zähler:" ; Z
Print #1 , "Loop"
Print #1 , "Ma: " ; Ma
Wait 3
Loop
Taste:
Print #1 , "Jetzt in ISR"
Select Case Ma
Case 1:
Print #1 , "Jetzt ganz in ISR"
Ma = 2
Case 2:
Ma = 1
End Select
Pcifr.0 = 1
Return
|
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Fri Dec 12, 2014 10:27 pm Post subject: |
|
|
Look up the help for "On Interrupt", it will give you the answer. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sat Dec 13, 2014 9:51 am Post subject: |
|
|
Hello,
Simply put you have Return within an if, the Compiler will only use a RETI (Return from Interrupt) for the first return that it sees outside conditions.
So modify your code to use IF,ELSE,ENDIF,RETURN
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
Visovian
Joined: 31 Oct 2007 Posts: 584 Location: Czech
|
Posted: Sat Dec 13, 2014 2:46 pm Post subject: |
|
|
I would try:
Code: | Taste:
Print #1 , "Jetzt in ISR"
If Ma = 1 Then
Ma = 2
Pcifr.0 = 1
Goto Fin
End If
Print #1 , "Jetzt ganz in ISR"
Pcifr.0 = 1
Ma = 1
Fin:
Return |
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|