Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20809

BASCOM-AVR : ATTINY2313, how can i set a regular interrupt, say 250ms : REPLY

$
0
0
When you want to use an interrupt, you have to do 3 steps. 1. Enable particular interrupt. E.g. ENABLE TIMER1 .......... TIMER1 overflow interrupt ENABLE OVF1 .............. the same ENABLE TIMER0 .......... TIMER0 overflow interrupt ENABLE COMPARE1A ... TIMER1 OUTPUT COMPARE A interrupt Look at Bascom help - ENABLE. There is a complete list of interrupt names. -------------------------------------------------------------------------- 2. Write the Interrupt Service Routine and tell Bascom its name. E.g. ON OVF2 Tim2_ovf ....... on timer2 overflow jump to subroutine Tim2_ovf: -------------------------------------------------------------------------- 3. Enable global interrupt ENABLE INTERRUPTS -------------------------------------------------------------------------- Register names: 16-bit compare value for Compare1a is in registers OCR1AH and OCR1AL. You can write OCR1AL = low (1000) OCR1AH = high (1000) Bascom introduces a name "COMPARE1A" for easy writing 16-bit value. COMPARE1A = 1000 ......... means write 1000 to OCR1AH:OCR1AL Similarly COMPARE1B .... = OCR1BH:OCR1BL CAPTURE1 ....... = ICR1H:ICR1L TIMER1 .............= TCNT1H:TCNT1L It may be a little confusing that these names are the same as names of interrupts.

Viewing all articles
Browse latest Browse all 20809

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>