Eeek, even a little bit of code like this....
is only toggling at 16khz - meaning that the main loop is only running at 30khz ...gulp (that's not leaving much room for anything else) bearing in mind I only have a 20khz sample rate going on...I wish the 16f1828 didn't have the ADC iissue about 8Mhz internal clock, becuase the obvious way of winning back por main loop time is to crank the internal clock up.Code:main: toggle PortC.4 'pin 6 'count1 = count1 +1 present_sample = ADRESH IF present_sample < 128 then present_sample = (127 - present_sample) else present_sample = present_sample -128 endif IF present_sample >= rolling_peak THEN rolling_peak = present_sample else if count1 = 50 and rolling_peak !=0 then rolling_peak = rolling_peak -1 count1 = 0 endif endif goto main




Bookmarks