i cant im a student and im not able to use another PIC typeUse a pic that has a PWM module.
Max.
im using assembly language not C and i want to know the delayC:while(1){ Turn on the port. Give appropriate delay. Turn off the port. Give appropriate delay. }
DELAY:How do you define a delay in assembly ?
; Delay = 1 seconds
; Clock frequency = 4 MHz
; Actual delay = 1 seconds = 1000000 cycles
; Error = 0 %
cblock
d1
d2
d3
endc
Delay
;999990 cycles
movlw 0x07
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
; Delay = 2 seconds
; Clock frequency = 4 MHz
; Actual delay = 2 seconds = 2000000 cycles
; Error = 0 %
cblock
d1
d2
d3
endc
Delay
;1999996 cycles
movlw 0x11
movwf d1
movlw 0x5D
movwf d2
movlw 0x05
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;4 cycles (including call)
return
can you explain to me how do i calculate how much time the delay will do ? for example i need a 2ms delayCode:; Delay = 1 seconds ; Clock frequency = 4 MHz ; Actual delay = 1 seconds = 1000000 cycles ; Error = 0 % cblock d1 d2 d3 endc Delay ;999990 cycles movlw 0x07 movwf d1 movlw 0x2F movwf d2 movlw 0x03 movwf d3 Delay_0 decfsz d1, f goto $+2 decfsz d2, f goto $+2 decfsz d3, f goto Delay_0 ;6 cycles goto $+1 goto $+1 goto $+1 ;4 cycles (including call) return
Where does the 2ms come in?can you explain to me how do i calculate how much time the delay will do ? for example i need a 2ms delay
i dont know how much cycle the pic will doClues: Use Timer 0, the instruction time is 1mhz for a 4mhz clock.
What fraction of a second is 1 cycle at 10Khz.
How much assembly have you done?
Max.
by Jeff Child
by Jake Hertz
by Duane Benson
by Duane Benson