Below is code for a programme i was mucking around with
basically using timers to flash led's on/off instead of loops
however anychip i burn the code too it prevents further erasing/reprogramming
i have tried 5 chips all with the same result - they are 16f628a / 16f648a
below is my code
i would like to know what the problem is that it 'kills' chips?????
Also how do i fix the code and how do ifix the chips if possible????
Many thanks
noel
;16f628A pin connections
; ra2 | | ra1 - output
; ra3 | | ra0 - output
; ra4 | | ra7
; ra5 | | ra6
; ground | | Supply
; rb0 | | rb7
; rb1 | | rb6
; rb2 | | rb5
; rb3 | | rb4
#DEFINE BANK0 BCF STATUS,5 ; define STATUS register bit 5 clear as BANK0
#DEFINE BANK1 BSF STATUS,5 ; define STATUS register bit 5 set as BANK1
#DEFINE T01F INTCON,2
#define T01E INTCON,5
#define TIMEROFF bcf T1CON,0
#define TIMERON bsf T1CON,0
list p=16f628a ; tell MPASM-type programmer to create a
; list (LST) file
include p16f628.inc ; bring in all standard register values
CBLOCK h'20'
BRIGHTNESS
ENDC
__config 0x3F18 ; internal 4MHz oscillator
ORG 0 ; reset vector
goto STARTIT
ORG 4 ;Interrupt Vector Address
;if an interrupt occurs the CPU will
;be directed to address $0004
;when the PIC is in programming mode it sets its
;internal counter to $0000 which is the reset
;vector address.The writer of the TASM
;programming toolkit decided to have
;it set this internal counter to $0005
;Thus .ORG $0004 must be used at the
;start of all TASM programs.
;Addresses $0001 to $0003 are not used with TASM
goto STARTIT
ORG 5 ; PIC program memory location at which to start
goto STARTIT
STARTIT BANK0
clrf PORTA ; clear PORTA's output if any
clrf PORTB ; clear PORTB's output if any
movlw 0x07 ; needed by some PICs, including PIC16F628
movwf CMCON ; so that PORTA is treated as digital port
BANK1
movlw b'00000000' ; all PORTA as output
movwf TRISA ; data direction register for PORTA
movlw b'00000000' ; PORTB as output
movwf TRISB ; data direction register for PORTB
bsf PIE1,0 ;enable interrupts
BANK0
movlw b'01111011' ; using compare tr2
movwf T2CON
movlw b'00111100'
movwf T1CON
movlw b'00001111'
movwf CCPR1L
movlw b'00001010'
movwf CCP1CON
;CLRWDT
movlw b'00000010'
movwf PORTA
goto LOOP
DELAY TIMEROFF
movlw 0xaa
movwf TMR1H
movwf TMR1L
bsf INTCON,6
bcf PIR1,0
TIMERON
btfsc PIR1,0
goto $+2
goto $-2
bcf PIR1,0
movlw b'00000001'
xorwf PORTA,f
return
LOOP bsf PORTA,3
call DELAY
bcf PORTA,3
call DELAY
goto LOOP
NOMORE goto NOMORE
END
basically using timers to flash led's on/off instead of loops
however anychip i burn the code too it prevents further erasing/reprogramming
i have tried 5 chips all with the same result - they are 16f628a / 16f648a
below is my code
i would like to know what the problem is that it 'kills' chips?????
Also how do i fix the code and how do ifix the chips if possible????
Many thanks
noel
;16f628A pin connections
; ra2 | | ra1 - output
; ra3 | | ra0 - output
; ra4 | | ra7
; ra5 | | ra6
; ground | | Supply
; rb0 | | rb7
; rb1 | | rb6
; rb2 | | rb5
; rb3 | | rb4
#DEFINE BANK0 BCF STATUS,5 ; define STATUS register bit 5 clear as BANK0
#DEFINE BANK1 BSF STATUS,5 ; define STATUS register bit 5 set as BANK1
#DEFINE T01F INTCON,2
#define T01E INTCON,5
#define TIMEROFF bcf T1CON,0
#define TIMERON bsf T1CON,0
list p=16f628a ; tell MPASM-type programmer to create a
; list (LST) file
include p16f628.inc ; bring in all standard register values
CBLOCK h'20'
BRIGHTNESS
ENDC
__config 0x3F18 ; internal 4MHz oscillator
ORG 0 ; reset vector
goto STARTIT
ORG 4 ;Interrupt Vector Address
;if an interrupt occurs the CPU will
;be directed to address $0004
;when the PIC is in programming mode it sets its
;internal counter to $0000 which is the reset
;vector address.The writer of the TASM
;programming toolkit decided to have
;it set this internal counter to $0005
;Thus .ORG $0004 must be used at the
;start of all TASM programs.
;Addresses $0001 to $0003 are not used with TASM
goto STARTIT
ORG 5 ; PIC program memory location at which to start
goto STARTIT
STARTIT BANK0
clrf PORTA ; clear PORTA's output if any
clrf PORTB ; clear PORTB's output if any
movlw 0x07 ; needed by some PICs, including PIC16F628
movwf CMCON ; so that PORTA is treated as digital port
BANK1
movlw b'00000000' ; all PORTA as output
movwf TRISA ; data direction register for PORTA
movlw b'00000000' ; PORTB as output
movwf TRISB ; data direction register for PORTB
bsf PIE1,0 ;enable interrupts
BANK0
movlw b'01111011' ; using compare tr2
movwf T2CON
movlw b'00111100'
movwf T1CON
movlw b'00001111'
movwf CCPR1L
movlw b'00001010'
movwf CCP1CON
;CLRWDT
movlw b'00000010'
movwf PORTA
goto LOOP
DELAY TIMEROFF
movlw 0xaa
movwf TMR1H
movwf TMR1L
bsf INTCON,6
bcf PIR1,0
TIMERON
btfsc PIR1,0
goto $+2
goto $-2
bcf PIR1,0
movlw b'00000001'
xorwf PORTA,f
return
LOOP bsf PORTA,3
call DELAY
bcf PORTA,3
call DELAY
goto LOOP
NOMORE goto NOMORE
END