list p=16F818 ; list directive to define processor
#include <p16F818.inc> ; processor specific variable definitions
__config H'3F10'
movlw b'01100000'
movwf OSCCON
cblock 0x0c
d1,d2,d3
endc
bsf STATUS,5
movlw 00h
movwf TRISA
bcf STATUS,5
START movlw 02h
movwf PORTA
call Delay2sec
movlw 00h
movwf PORTA
call Delay2sec
goto START
Delay2sec
;1999996 cycles
movlw 0x11
movwf d1
movlw 0x5D
movwf d2
movlw 0x05
movwf d3
Delay2sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay2sec_0
;4 cycles (including call)
return
END
Configuration Bits
__CONFIG H'3F10'
;sets INTRC-A6 is port i/o
;WDT off
;PUT on
;MCLR tied to VDD
;A5 is I/O
;BOD off
;LVP disabled
;Flash Program Write disabled
;Background Debugger disabled
;CCP function on B2
;Code Protection disabled
list p=16F818 ; list directive to define processor
#include <p16F818.inc> ; processor specific variable definitions
errorlevel -302, -207
__config H'3F10'
cblock 0x20;[COLOR="Red"]0c[/COLOR]
d1,d2,d3
endc
org 0x0000
movlw b'01100000'
movwf OSCCON
bsf STATUS,5
movlw 00h
movwf TRISA
bcf STATUS,5
START movlw 02h
movwf PORTA
call Delay2sec
movlw 00h
movwf PORTA
call Delay2sec
goto START
Delay2sec
;1999996 cycles
movlw 0x11
movwf d1
movlw 0x5D
movwf d2
movlw 0x05
movwf d3
Delay2sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay2sec_0
;4 cycles (including call)
return
END
Thanks eric
Can you explain these lines
Code:cblock 0x20;0c
& this one
Code:org 0x0000
& this one
Code:errorlevel -302, -207
Thanks eric
Can you explain these lines
The PIC uses registers 0x00 thru 0x1F for its internal use, the general purpose free registers for the user start at 0x20 [20h]Code:cblock 0x20;0c
& this one
Code:org 0x0000
You should set the ORIGIN, its where you set the program counter start address
& this one
Code:errorlevel -302, -207
On the MPLAB IDE assembler you get irritating warnings about the Bank selection, every time you assemble,, this line disables the warning message
Sorry of the troubles
Thanks in advance
Hmm thanks for the explaination I like it!!!!!!!
BTW, its still not working I will post my circuit i am using
movlw [COLOR="Red"]02h[/COLOR];;; 01h
movwf PORTA
call Delay2sec
movlw 00h
movwf PORTA
Still not working!!!
Here is the update of my schematic thanks eric for spotting that out.
Here is what happen When i turn the power supply on the LED lights on and keep lighting on.
BTW, if you can help me thanks again
I print screen my config so you can have a look into it
Thanks for replying
bsf STATUS,5
movlw 00h
movwf TRISA
movlw b'01100000'
movwf OSCCON
bcf STATUS,5
General question?
Does all PIC contain PWM? If not does PIC 16F84a or PIC 16F818 contains it?
I am trying to control a servo motor using PWM i need to send a signal of 1ms to reach 0 degree 2ms to reach 180degree and so on.
General question?
Does all PIC contain PWM? If not does PIC 16F84a or PIC 16F818 contains it?
I am trying to control a servo motor using PWM i need to send a signal of 1ms to reach 0 degree 2ms to reach 180degree and so on.
list p=16F818 ; list directive to define processor
#include <p16F818.inc> ; processor specific variable definitions
errorlevel -302, -207
__config H'3F10'
cblock 0x20
d1,d2,d3
endc
org 0x0000
bsf STATUS,5
movlw 00h
movwf TRISA
movlw b'01100000'
movwf OSCCON
bcf STATUS,5
START movlw 02h
movwf PORTA
call Delay1ms
movlw 00h
movwf PORTA
call Delay1ms
goto START
Delay1ms
;993 cycles
movlw 0xC6
movwf d1
movlw 0x01
movwf d2
Delay1ms_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay1ms_0
;3 cycles
goto $+1
nop
;4 cycles (including call)
return
END
Look at Nigels tutorials for PWM examples.
I thought - WHERE?
Then I remembered, it's NOT for servo control, but just a simple example of how to use the two channel hardware PWM for speed and direction control of a small robot. I added it specifically because I was getting multiple questions a week about how to do this using the PWM modules.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?