moschino891129
Junior Member level 1
First I want to say sorry for my "English"
So now I can continue with HI ALL
I am very new in microcontrollers and I have only the basic knowledge for electronics ... I hope to start my adventure with this project -
https://www.instructables.com/id/Super-Easy-Reversible-Motor-Control-for-Arduino-/
but I have a problem with the software part of challenge... in the tutorial the author says "It's not rocket science" about the code, but for me IT LOOKS LIKE ROCKET SCIENCE (I mean the asembler code for this function ).
So anyway , can you people help me with converting the code to asembler usable for pic16f84a and if it's posible to be with more coment (cuz I want to understand what evrything means)?
I tried to write the code using combination of two codes - first code which turns ON and OFF LED for some delay and second code with PWM which dims the LED , but I faild ... evrything I made was to dim the LED but I can't escape from the pwm loop of my code ...
May be this will be very funny for you people but I will share my bullshits
there is :
So now I can continue with HI ALL
I am very new in microcontrollers and I have only the basic knowledge for electronics ... I hope to start my adventure with this project -
https://www.instructables.com/id/Super-Easy-Reversible-Motor-Control-for-Arduino-/
but I have a problem with the software part of challenge... in the tutorial the author says "It's not rocket science" about the code, but for me IT LOOKS LIKE ROCKET SCIENCE (I mean the asembler code for this function ).
So anyway , can you people help me with converting the code to asembler usable for pic16f84a and if it's posible to be with more coment (cuz I want to understand what evrything means)?
I tried to write the code using combination of two codes - first code which turns ON and OFF LED for some delay and second code with PWM which dims the LED , but I faild ... evrything I made was to dim the LED but I can't escape from the pwm loop of my code ...
May be this will be very funny for you people but I will share my bullshits
there is :
Code:
list p=16f84
radix hex
#include <p16F84A.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
w EQU 0
f EQU 1
Counter EQU H'0C'
portb equ 0x06 ; port b equate
duty equ 0x0c ; length of duty cycle
temp equ 0x0d ; length of duty cycle
c equ 0
start bsf STATUS,RP0
movlw B'11010111'
movwf OPTION_REG
bcf STATUS,RP0
clrf PORTB
bsf STATUS,RP0
movlw B'11111110'
movwf TRISB
bcf STATUS,RP0
goto main
ACTA movlw 0x00 ; load W with 0x00 make port B output
tris portb ; copy W tristate to port B outputs
movlw 0x00 ; fill w with zeroes
movwf portb ; set port b outputs to low
rstrt movlw d'0'
movwf portb
movlw d'10' ; Duty cycle length
movwf duty
b0loop movf duty,w
movwf temp
bsf portb,0
pwma nop
nop
nop
decfsz temp
goto pwma
movlw d'255'
movwf temp
movf duty,w
subwf temp,f
bcf portb,0
pwmb nop
nop
nop
decfsz temp
goto pwmb
goto rstrt
return
WaitA movlw D'30'
movwf Counter
clrf TMR0
againA bcf INTCON,T0IF
loopA btfss INTCON,T0IF
goto loopA
decfsz Counter,f
goto againA
return
ACTB movlw 0x00 ; load W with 0x00 make port B output
tris portb ; copy W tristate to port B outputs
movlw 0x00 ; fill w with zeroes
movwf portb ; set port b outputs to low
rstrtB movlw d'0'
movwf portb
movlw d'200' ; Duty cycle length
movwf duty
b0loopB movf duty,w
movwf temp
bsf portb,0
pwmaB nop
nop
nop
decfsz temp
goto pwma
movlw d'255'
movwf temp
movf duty,w
subwf temp,f
bcf portb,0
pwmbB nop
nop
nop
decfsz temp
goto pwmbB
goto rstrtB
return
WaitP movlw D'30'
movwf Counter
clrf TMR0
againP bcf INTCON,T0IF
loopP btfss INTCON,T0IF
goto loopP
decfsz Counter,f
goto againP
return
main
call ACTA
call WaitA
call WaitP
call ACTB
call WaitA
call WaitP
goto main
END
Last edited by a moderator: