Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Atmega 8 hangup

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
sakaz

Bascom Member



Joined: 02 May 2007
Posts: 99

blank.gif
PostPosted: Sun Apr 27, 2008 6:29 pm    Post subject: Atmega 8 hangup Reply with quote

Hi forum,

I have been working with some projects but i dont know why the AVR hangs after some time. I made the system which works with phone calls and turn on./off switch with the DTMF tones Everything is working fine my codes but after make 5 or 6 calls the system restart or stop to receive anything on the USART. I have tried to change stack settings too but still not working.

$regfile = "m8def.dat"
$crystal = 4000000
$baud = 19200
$hwstack = 150
$swstack = 32
$framesize = 32

--------------


Rs232_isr:
Chrx = Udr

Select Case Chrx
Case 0
Case 13
Case 10 : Kk = Str2$
Str2$ = ""
Flag_data_ready = 1
Case Else
If Len(str2$) < Max_buf_len Then 'Filter out LF and CR etc
Str2$ = Str2$ + Chr(chrx)
Else
End If
End Select


Return

--------
I am totally fade up why the system is not working and i need to always working the system. waiting for your quick reply.

Shan
Back to top
View user's profile
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 375
Location: Wuppertal, Germany

germany.gif
PostPosted: Wed Apr 30, 2008 10:59 am    Post subject: Reply with quote

itīs never a good idea to do many things in an ISR.
Try to change your prog in an way like this:

Rs232_isr:
Chrx = Udr
Flag_new_data = 1
return

let the rest be done in your main loop, depending on Flag_new_data.

Itīs just an idea, but give it a try!
And post the result, please!
Back to top
View user's profile
sakaz

Bascom Member



Joined: 02 May 2007
Posts: 99

blank.gif
PostPosted: Wed Apr 30, 2008 4:16 pm    Post subject: Reply with quote

Hi Arera,

Thank you very much for your reply with your advice to make the ISR shorter. I have been working on my project and reading code for last whole night and finally i got the error and problem why the AVR is going to Reset or Hang up. Ok i try to tell you the reason. As per my main loop below:

Do

If Flag_data_ready = 1 Then
If Len(kk) > 2 Then
Flag_data_ready = 0
End If

If Mid(kk , 1 , 4) = "RING" Then
Incall_flag = 0
Start Timer1
Gosub Glock
End If

Else

End If

Gosub Doorcheck
Set Portd.6
Waitms 500
Reset Portd.6
Waitms 500

Loop

End


When we detect "RING" from Modem then it call the SUB GLOCK so it take 2 bytes from the HWSTACK and the problem was i used the GOTO Statement instead of RETURN because. When we call a sub it take 2 bytes from HWSTACK and when we use RETURN then it give back the 2 bytes and the error was here when i called once the SUB GLOCK then it take 2 bytes then again 2 + + + and the result was ..

The HWSTACK grow down first to the SWSTACK then FREME and then DATA Area and which make the AVR hangup or Reset / Restart.

I hope that would be helpful for others who are facing problem with overflow and avoid that problem.

Regards,
Shan
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive 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