Thanks for your help.
So I've tried first to set a fixed reload value (64594) without calculations (to obtain 120Hz sine, the max. frequency). The sine wave was perfectly stable on the oscilloscope.
This :
dum=dum1*dum2
reload=DIV32 freq
reload=(65535-reload)+8
was removed and replaced with :
I've also applied Henrik tips, like this :
Code:
' Frequency reference control by potentiometer
potsense=(potsense<<6)**maxfreq
IF potsense<>freq THEN
freq=potsense
flag=%1
endif
And set the reload calculation routine into the main loop.
Results : it's more stable, but the glitches still appears when I change the frequency of the sine (so the reload calculation routine is executed during this time).
I'm pretty sure that the problem is caused by DIV32. However this routine is needed :
dum=dum1*dum2
reload=DIV32 freq
reload=(65535-reload)+8
How to replace the "DIV32" by an another thing? It is possible to use that : http://melabs.com/resources/fp.htm ? Or anything else?
Bookmarks