How can we display pulses at GPIO4 and GPIO5 at the same time in PIC12f629

DISPLAY ON OSCILLOSCOPE

I have created a simple program to generate pulses.

I want to see 1 pulse on GPIO4 and other on GPIO5

But the delay in the loops are getting added and I am not getting the desired result.

Following is my code:

I have not mentioned the variables definition here.

movlw .44 ;on time of pulse #1
movwf M1
movlw .44 ;off time of pulse #1
movwf M2

movlw .160 ;on time of pulse #1
movwf M3
movlw .160 ;off time of pulse #1
movwf M4


goto main

main:

call lowtest,hightest
;decfsz COUNTER,1
;call hightest
goto main

;goto loop1


lowtest:
bsf GPIO,5
call Delay
bcf GPIO,5
call Delay1
return

Delay movf M1,0
movwf COUNTER
nop
decfsz temp,f
goto $-2
decfsz COUNTER,f
goto $-4
retlw 00


Delay1 movf M2,0
movwf COUNTER1
nop
decfsz temp1,f
goto $-2
decfsz COUNTER1,f
goto $-4
retlw 00

;loop1:

hightest:
bsf GPIO,4
call Delay2
bcf GPIO,4
call Delay3
return

Delay2 movf M3,0
movwf COUNTER2
nop
decfsz temp2,f
goto $-2
decfsz COUNTER2,f
goto $-4
retlw 00

Delay3 movf M4,0
movwf COUNTER3
nop
decfsz temp3,f
goto $-2
decfsz COUNTER3,f
goto $-4
retlw 00

end
 
Slow your pulses down enough to see em flash LEDs then debug. don't need a scope. Just introduce a common delay loop, perhaps one with 3, 8 bit variables nested to slow things down enough. Remember at 4Mhz a single instruction takes 1 us, a goto or call takes 2 us, so u can predict loop timings exactly.
 
but slowing down will not give me the exact frequency.

I am not able to get two pulses of the desired frequency.

The delays are getting added and hence the frequency of the pulses are affected.

Is there any way I can avoid this?

I have the delay loops for both pulse generated in the same code.
I want to know how I can keep the delay loops for first pulse isolated from 2nd.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…