hi guys, here's my program sample.
It is just to set RA0 (pin 17) to HIGH for 1.5ms and then LOW for 18.5ms.
Is my sample program correct?
I saw some sample programs in the internet, they include something like this after include<pic16f88.inc>
If there is anything wrong in the program, please let me know.
In addition, if I want this program to run just for 1 minute, what should be modified or in what way the code should be written?
Oh, and also, I can write using hexadecimal, binary, and decimal in 1 program, can't I?
Thank you.
Regards.
It is just to set RA0 (pin 17) to HIGH for 1.5ms and then LOW for 18.5ms.
HTML:
list p=16f88
#include <pic16f88.inc>
osccon equ 8fh
status equ 03h
porta equ 05h
portb equ 06h
ansel equ 9bh
trisa equ 85h
trisb equ 86h
cblock 20h
d1
d2
d3
endc
org 0x000
main ;initialisiing ports and clock
;********setting the internal RC clock frequency
call banksel1
movlw 01101110 ;freq = 4MHz, bit 1 and 0 are 10 because internal RC is used for the system clock
movwf osccon
clrf ansel ;setting all pins to digital pins
clrf trisa ;setting all port A into output
clrf trisb ;setting all port B into output
call banksel0
clrf porta;set all port A into LOW
clrf portb;set all port B into LOW
mainloop ;the main loop
bsf porta,0 ;set pin 17 HIGH
call delay1.5ms
bcf porta,0 ;set pin 17 LOW
call delay18.5ms
goto mainloop
;***bank selections***
banksel0
bcf status,5
bcf status,6
return
banksel1
bsf status,5
bcf status,6
return
;***delay routine***
;*delay variables
delay1.5ms ;total of 1,500,004 cycles
movlw odh
movwf d1
movlw 46h
movwf d2
movlw 04h
movwf d3
goto delay
return
delay18.5ms ;total of 18,500,003 cycles
movlw a8h
movwf d1
movlw 54h
movwf d2
movlw 29h
movwf d3
goto delay
return
;*actual delay routine
delay
decfsz d1,f
goto $+2
decfsz d2,f
goto $+2
decfsz d3,f
goto delay
return
Is my sample program correct?
I saw some sample programs in the internet, they include something like this after include<pic16f88.inc>
HTML:
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _INTRC_OSC_CLKOUT & _MCLRE_OFF & _LVP_OFF
If there is anything wrong in the program, please let me know.
In addition, if I want this program to run just for 1 minute, what should be modified or in what way the code should be written?
Oh, and also, I can write using hexadecimal, binary, and decimal in 1 program, can't I?
Thank you.
Regards.
Last edited: