Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Return in ISR -- AVR Reset ??

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Jogi864

Bascom Member



Joined: 05 Oct 2010
Posts: 2

PostPosted: Fri Dec 12, 2014 10:01 pm    Post subject: Return in ISR -- AVR Reset ?? Reply with quote

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
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2335

blank.gif
PostPosted: Fri Dec 12, 2014 10:27 pm    Post subject: Reply with quote

Look up the help for "On Interrupt", it will give you the answer.
Back to top
View user's profile
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1571
Location: Basel, Switzerland

switzerland.gif
PostPosted: Sat Dec 13, 2014 9:51 am    Post subject: Reply with quote

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
View user's profile
Visovian

Bascom Member



Joined: 31 Oct 2007
Posts: 584
Location: Czech

czechrepublic.gif
PostPosted: Sat Dec 13, 2014 2:46 pm    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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