wp100
Advanced Member level 6
- Joined
- May 15, 2009
- Messages
- 3,051
- Helped
- 884
- Reputation
- 1,783
- Reaction score
- 733
- Trophy points
- 113
- Location
- Prime Meridian
- Activity points
- 0
Hi,
Its a great feeling when you get you first project working.
The code I use is called Assembly, a very Low level language where you have to tell it line by line what to do; its very different to High level languages like C.
Here is my 'flasher' code, you use it with the Assembler program built in to Mplab.
Its a great feeling when you get you first project working.
The code I use is called Assembly, a very Low level language where you have to tell it line by line what to do; its very different to High level languages like C.
Here is my 'flasher' code, you use it with the Assembler program built in to Mplab.
Code:
; specify basic chip information and Configuration
list p=16f877a
include p16f877a.inc
__CONFIG _CP_OFF & _WDT_OFF & _HS_OSC & _PWRTE_ON & _LVP_OFF
; set up user variables / registers/ work files
cblock 0X30
d1
d2
d3
COUNT
endc
; start of program code
org 0x00
GOTO Main
org 0x04
RETFIE
; set up the i/o port for your needs
Main CLRF PORTB ; SET portb,c,d to outputs
CLRF PORTD
CLRF PORTC
BANKSEL TRISA
CLRF TRISB
CLRF TRISC
CLRF TRISD
BANKSEL 0
; the 'actual' program loop
loop bsf PORTB,0
CALL DELAY1
bcf PORTB,0
CALL DELAY1
GOTO LOOP
; the Called Subroutine, Delay = 1 seconds = 1000000 cycles with a 4Mhz oscillator
DELAY1
movlw 0x08
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
return
END