View previous topic :: View next topic |
Author |
Message |
uga237
Joined: 15 May 2012 Posts: 32
|
Posted: Tue Mar 26, 2013 3:37 pm Post subject: call sub in interrupt |
|
|
$regfile = "xm256A3def.dat"
$crystal = 32000000
$hwstack = 1024
$swstack = 1024
$framesize = 1024
Const Pda_pcb_ver = 2
Config Submode = New
'first enable the osc of your choice
Config Osc = Enabled , Pllosc = Disabled , Extosc = Disabled , 32khzosc = Disabled , 32mhzosc = Enabled '32MHz
'configure the systemclock
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1 '32MHz
Declare Sub Func_1(byval Byte_ctr As Word , Byval Byte_ctr1 As Word , Byval Byte_ctr2 As Word , Byval Byte_ctr3 As Word)
Declare Sub Func_2(byval Byte_ctr As Word , Byval Byte_ctr1 As Word , Byval Byte_ctr2 As Word , Byval Byte_ctr3 As Word)
Declare Sub Pilik()
'INIT
'Buzz init
#if Pda_pcb_ver = 2
Buzz Alias Portc.1
Config Buzz = Output
Const Buzz_on = 1
Const Buzz_off = 0
Buzz = Buzz_off
#endif
'End Buzz init
'TC
Config Tcf0 = Normal , Prescale = 64
Tcf0_per = 1000 ' 500Hz
On Tcf0_ovf Tcf0_isr
Enable Tcf0_ovf , Lo 'Enable this Interrupt as Lo Level Interrupt
'End TC
'=============MAIN==============
Config Priority = Roundrobin , Vector = Application , Lo = Enabled 'Enable Lo Level Interrupts
Enable Interrupts
Call Pilik()
Call Pilik()
Do
Call Func_1(1 , 2 , 3 , 4 )
Waitus 500
Loop
Tcf0_isr:
Call Func_2(1 , 2 , 3 , 4 )
Return
Sub Func_1(byval Byte_ctr As Word , Byval Byte_ctr1 As Word , Byval Byte_ctr2 As Word , Byval Byte_ctr3 As Word)
If Byte_ctr <> 1 Then
Call Pilik()
End If
If Byte_ctr1 <> 2 Then
Call Pilik()
End If
If Byte_ctr2 <> 3 Then
Call Pilik()
End If
If Byte_ctr3 <> 4 Then
Call Pilik()
End If
End Sub
Sub Func_2(byval Byte_ctr As Word , Byval Byte_ctr1 As Word , Byval Byte_ctr2 As Word , Byval Byte_ctr3 As Word)
nop
End Sub
Sub Pilik()
Sound Buzz , 90 , 1000
Sound Buzz , 90 , 500
Sound Buzz , 90 , 700
End Sub
Some time hear "pilik"
(BASCOM-AVR version : 2.0.7.6 ) |
|
Back to top |
|
|
uga237
Joined: 15 May 2012 Posts: 32
|
Posted: Tue Mar 26, 2013 3:42 pm Post subject: |
|
|
Avr dbg |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Mar 26, 2013 4:05 pm Post subject: |
|
|
when calling user functions/subs from interrupts you need :
$frameprotect = 1 _________________ Mark |
|
Back to top |
|
|
uga237
Joined: 15 May 2012 Posts: 32
|
Posted: Tue Mar 26, 2013 4:11 pm Post subject: |
|
|
Thank you. I search solve this error 7 days... but it easy )))
Why it is off by default in 2076? |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Mar 26, 2013 4:17 pm Post subject: |
|
|
because it is not recommended to call user subs from an interrupt. when it would be on by default, it generates more code.
so this option is only for the user that really want to call user functions from interrupts which pass variables byval. _________________ Mark |
|
Back to top |
|
|
uga237
Joined: 15 May 2012 Posts: 32
|
Posted: Tue Mar 26, 2013 4:31 pm Post subject: |
|
|
"because it is not recommended to call user subs from an interrupt." - filosofy )
In r3,sreg
cli
...
Out sreg,r3
This no big code )
may be add info about "By default the frame protection is off. " in FAQ or "Newbie problems"? |
|
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
|
|