Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Interrupt every 4 microseconds

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

Bascom Member



Joined: 15 Nov 2008
Posts: 18

italy.gif
PostPosted: Tue Mar 26, 2024 3:21 pm    Post subject: Interrupt every 4 microseconds Reply with quote

Hi,

with the attached program I get interrupts every 16 microseconds but
I would like to have it every 4 microseconds

Thanks


$regfile = "m128def.dat"
$baud = 9600
$baud1 = 9600
$hwstack = 94
$swstack = 94
$framesize = 94
$crystal = 16000000
' Output
Ddre.6 = 1
'
Dim A1 As Byte
Led Alias Porte.6
'
Config Timer2 = Timer , Prescale = 1
On Timer2 Dec_timer
On Ovf0 Dec_timer
Enable Timer2
'
Enable Interrupts
'
Do
Loop
'
'
Dec_timer:
Toggle Led
Return

(BASCOM-AVR version : 2.0.7.8 , Latest : 2.0.8.6 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5922
Location: Holland

blank.gif
PostPosted: Tue Mar 26, 2024 3:34 pm    Post subject: Reply with quote

you need to adjust the timer count value.
now it count to 255 and it flows over.
so preset it so it overflows earlier
when time is 16 us now, divide 256 by 4 is 64 times 3 makes 192

also set this value in the ISR after the toggle : tcnt2=192

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR old unsupported versions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can 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