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

BASCOM-AVR : pulse length capture : REPLY

$
0
0
hi Adrian indeed it'working: even with or whitout ASM code like proposed in datasheet. It make no difference at first sight. [code:1:3cd80f3144]Int1_isr: Stop Timer1 'L = Tcnt1l 'H = Tcnt1h 'Hl = H * 256 'Hl = Hl + L !in r18,sreg 'save global interr flag !cli 'disable interrupts Hl = Timer1 !sei 'enable interr !out sreg,r18 'restore global interr flag Return '------------------- Timer1_isr: Portb.4 = 0 Return[/code:1:3cd80f3144] I do not understand ASM, but i found a ASM listing that makes a extra 6 bits in software. There is a loop waiting on a stop-flag while TOV1 is constantly monitored. But i do understand not at all. [code:1:3cd80f3144]Measure_t: Period = &H7FFFFFFF 'set t>> (it will be corrected if measuring is OK) in r24,tccr0b ori r24,$40 sbic pinb,0 'If Pinb.0(=OC0B) = 1 then !out tccr0b,r24 'force compare match to clear OC0B in r24,tifr ori r24,$86 'clear TIFR.TOV1,.TOV0,.OCF0B !out tifr,r24 ldi r24,0 !out tcnt0,r24 'Timer0 = 0 !out tcnt1h,r24 !out tcnt1l,r24 'Timer1 = 0 ldi r26,0 ldi r27,0 lds r28,{tmax+0} lds r29,{tmax+1} 'set max measuring time ldi r30,0 'Timer1 extension = 0 lds r31,{sw12} 'R31.6 = 0(hold)/1(run) in r24,eifr ori r24,$40 'clear EIFR.INTF0 (clear pending external interrupt) !out eifr,r24 in r24,gimsk ori r24,$40 !out gimsk,r24 'Enable Int0 Measure_wait: 'loop until ... in r24,gimsk andi r24,$C0 breq measure_ok '...end of measuring rcall Check_tifr.tov1 cpi r26,105 brsh measure_wait1 nop nop Measure_wait1: sbrs r31,6 rjmp measure_wait sbiw r26,2 brne measure_wait sbiw r28,1 brne measure_wait '...measuring time elapsed[/code:1:3cd80f3144] source acknowledged: Elektor: a intervalmeter with ATtiny2313. Would this be applicable in Bascom with AtMega16? Are the registers the same?

Viewing all articles
Browse latest Browse all 20688

Trending Articles



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