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

BASCOM-AVR : pulse length capture : REPLY

$
0
0
hello i'm positively surprised that it functions notwithstanding this simple code. There is no take account of lost of bits during stops or time delays. Only on the first transit from 65535 to 65536 there is a little hesitance: 65535-2-4-65340, but from 2^17 on its running smoothly. Maybe it's better to solve that problem, but at this moment i dont know if that will have bad consequences. The calculation is in the INT1_isr and not in the main loop, otherwise the print is distordet, i dont why. I have such a intervalmeter from Elektor with more elaboreted ASM code. There is take account of all this lost bits and i have just the same readings, maybe a little difference caused by different crystals. In theory i can read to more than 100sec or 0.01Hz in a resolution of 0.0625µSec. [code:1:46e05a5f08] Dim Ovf1 As Long Do If Hl <> Hl_old Then Print Hl Hl_old = Hl End If Loop End '------------------ Int0_isr: Ovf1 = 0 Timer1 = 0 'reset timer Start Timer1 Return '------------------ Int1_isr: Stop Timer1 L = Tcnt1l H = Tcnt1h Hl = H * 256 Hl = Hl + L Ovf1 = Ovf1 * 65536 Hl = Hl + Ovf1 '!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: Incr Ovf1 Return[/code:1:46e05a5f08]

Viewing all articles
Browse latest Browse all 20795

Trending Articles



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