If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
Dear KingJL, could you explain how in your code can be changed by Sample_Delay 49,5uS about 75 or 100uS.
With respect.
The default Sample 1 delay is controlled by 'Def_Dly', defined in the 'Constants' section. The constant is set to: (desired delay - 1.5) / 1.5. Example (49.5 - 1.5) / 1.5 = 32, so Def_Dly equ 0x20. And the SAMPLE_DELAY adjustment is limited in the code to 49.5 usec. To get a SAMPLE 1 delay greater than 49.5usec would require a rewrite of the code. When this this code was written, it was with the goal of timing accuracy (minimum jitter) and interrupt code efficiency.
The default Sample 1 delay is controlled by 'Def_Dly', defined in the 'Constants' section. The constant is set to: (desired delay - 1.5) / 1.5. Example (49.5 - 1.5) / 1.5 = 32, so Def_Dly equ 0x20. And the SAMPLE_DELAY adjustment is limited in the code to 49.5 usec. To get a SAMPLE 1 delay greater than 49.5usec would require a rewrite of the code. When this this code was written, it was with the goal of timing accuracy (minimum jitter) and interrupt code efficiency.
You can try this (no guarantees... this code was written a long time ago):
In the sequence (right near the end of the code):
banksel ADRESH
movfw ADRESH
addlw 0x08 ; set range to 2-33 for delay of 3uS-49.5uS
andlw 0xf8 ; clear bits 0,1,2 so no rotate thru carry
movwf SAMPLE_DELAY ;Store AD hibyte
rrf SAMPLE_DELAY ;divide by 8 to get a range of 2-33uS
rrf SAMPLE_DELAY
rrf SAMPLE_DELAY
bcf STATUS,RP0
goto Idle_loop
change the lines:
addlw 0x08 ; set range to 2-33 for delay of 3uS-49.5uS
andlw 0xf8 ; clear bits 0,1,2 so no rotate thru carry
to
addlw 0x04 ; set range to 2-63 for delay of 3uS-99uS
andlw 0xfC ; clear bits 0,1 so no rotate thru carry
and comment out the last 'rrf SAMPLE_DELAY' line:
; rrf SAMPLE_DELAY
This will definitely reduce the granularity of the delay control, but should provide for a delay of up to about 99 usec (if I remember correctly).
Last edited by KingJL; 02-10-2016, 05:15 PM.
Reason: correction of comment
Comment