3BABY
Member level 5
- Joined
- Jan 14, 2011
- Messages
- 91
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- New Zealand
- Activity points
- 2,252
Hi Guys,
i have googled and searched but the 16F887 seems to be harder to get working then a 18F4550.. can someone please point out the obvious mistake im making in the below? im only working with the 16F887 as i have run out of 18F4550's... any help would save my sanity greatly!!!!
i have googled and searched but the 16F887 seems to be harder to get working then a 18F4550.. can someone please point out the obvious mistake im making in the below? im only working with the 16F887 as i have run out of 18F4550's... any help would save my sanity greatly!!!!
Code:
;**************************************************************************************************
;
; Target: PIC16F887
; Oscillator: 8Mhz
;
;
;**************************************************************************************************
LIST p=16F887 ;tell assembler what chip we are using
#include<p16f887.inc>
__config 0x1D19 ;sets the configuration settings (oscillator type etc.)
;-------- Register Definitions------
W EQU H'0000'
F EQU H'0001'
;-------- Register Files----
d10 EQU 0x50
d11 EQU 0x51
d12 EQU 0x52
d13 EQU 0x53
;------------ Port Settings --------------------------------------
ORG 0
;------------ Port Settings --------------------------------------
BSF STATUS,5 ;Switch to Bank 1
CLRF PORTB ;PORTB is output
MOVLW b'00000000'
MOVWF TRISB
bcf STATUS,5 ;Switch back to Bank 0
;------------------------------------ MAIN PROGRAM ------------------------------------------------------------------
START
CLRF PORTB
MAIN
MOVLW b'11111111'
MOVWF PORTB
CALL DELAY_10SECS
NOP
MOVLW b'00000000'
MOVWF PORTB
CALL DELAY_10SECS
NOP
GOTO MAIN
;------ DELAY_10SECS - 10 Seccond delay --------------------------------------------------------------------------------------------
DELAY_10SECS
; Delay = 10 seconds
; Clock frequency = 8 MHz
; Actual delay = 10 seconds = 20000000 cycles
; Error = 0 %
; cblock
; d10
; d11
; d12
; endc
;19999992 cycles
movlw 0xB5
movwf d10
movlw 0x99
movwf d11
movlw 0x2C
movwf d12
Delay_10_1
decfsz d10, f
; goto $+2
goto D10_2
decfsz d11, f
D10_2
goto D10_3
decfsz d12, f
D10_3
goto Delay_10_1
;4 cycles
;goto $+1
;goto $+1
NOP
NOP
NOP
;4 cycles (including call)
return
;----------------------------------------------------------------------------------------------------------------------------------------
END