komita
Newbie level 3
Hello everybody, after a long time I am trying to get back to my favorite hobby .. electronics.
I am trying to get familiar with PIC programming but I am having some trouble.
Attached is a picture of my circuit design in Multisim, and following is the code from the PIC.
What I am trying to accomplish is get the pic to tun on both LED's for a few seconds then turn them off for a few seconds. But what ends up happening is they blink very quickly and then stay turned off for a few seconds. I suspect a programming mistake but cannot find it.
(on a side note, I am just beginning to design circuits myself and was wondering if you could tell me what I have done wrong/right on this one, as you can see the output voltage at the LED's is around 1.055V (for the split second they are on)/ Why so low? I was looking for something close to 5V similar to the input?
Any help appreciated.
CODE:
########################################
#include "p16f84a.inc" ; This includes PIC16F84A definitions for the MPASM assembler
STATUS equ 0x03
TRISA equ 0x85
TRISB equ 0x86
PORTA equ 0x05
PORTB equ 0x06
COUNT1 equ 08h
COUNT2 equ 09h
GOTO START
START
;BCF STATUS, RP0 ;BANK 0
CLRF PORTA ;clear bth ports statuses to zero
CLRF PORTB
BSF STATUS,5 ;set the 5th bit of status register to on (this transfers us to Bank 1 to manipulate settings)
MOVLW b'0000000' ;mpve zeros to working
MOVWF PORTB ;then move them to portb statuses (mening output)
MOVLW b'111' ;set this to working
MOVWF PORTA ;then set porta to input
BCF STATUS,5 ;set the 5th bit of status register to zero (this transfers us to Bank 0 to manipulate values)
REDO
CLRF PORTB ; set all zeros to portB
movlw 0xFF ;First put the value of b255 in the W register
movwf COUNT1 ;Now move it to our 08h register.
movlw 0x2 ;First put the value of b2 in the W register for the second count (so it will be 255 x 2 = 510)
movwf COUNT2 ;Now move it to our 09h register
Loop2
decfsz COUNT1,1 ;Subtract 1 from 255
goto Loop2 ;If COUNT is zero, carry on.
decfsz COUNT2,1 ;Subtract 1 from 255
goto Loop2 ;Go back to the start of our loop.
MOVLW b'1111111'
MOVWF PORTB
movlw 0xFF ;First put the value of b255 in the W register
movwf COUNT1 ;Now move it to our 08h register.
movlw 0x2 ;First put the value of b2 in the W register for the second count (so it will be 255 x 2 = 510)
movwf COUNT2 ;Now move it to our 09h register
Loop1
decfsz COUNT1,1 ;Subtract 1 from 255
goto Loop1 ;If COUNT is zero, carry on.
decfsz COUNT2,1 ;Subtract 1 from 255
goto Loop1 ;Go back to the start of our loop.
GOTO REDO
END
#################################################
---------- Post added at 18:50 ---------- Previous post was at 18:50 ----------
CIRCUIT:
###################################################################################
**broken link removed**
Uploaded with ImageShack.us
I am trying to get familiar with PIC programming but I am having some trouble.
Attached is a picture of my circuit design in Multisim, and following is the code from the PIC.
What I am trying to accomplish is get the pic to tun on both LED's for a few seconds then turn them off for a few seconds. But what ends up happening is they blink very quickly and then stay turned off for a few seconds. I suspect a programming mistake but cannot find it.
(on a side note, I am just beginning to design circuits myself and was wondering if you could tell me what I have done wrong/right on this one, as you can see the output voltage at the LED's is around 1.055V (for the split second they are on)/ Why so low? I was looking for something close to 5V similar to the input?
Any help appreciated.
CODE:
########################################
#include "p16f84a.inc" ; This includes PIC16F84A definitions for the MPASM assembler
STATUS equ 0x03
TRISA equ 0x85
TRISB equ 0x86
PORTA equ 0x05
PORTB equ 0x06
COUNT1 equ 08h
COUNT2 equ 09h
GOTO START
START
;BCF STATUS, RP0 ;BANK 0
CLRF PORTA ;clear bth ports statuses to zero
CLRF PORTB
BSF STATUS,5 ;set the 5th bit of status register to on (this transfers us to Bank 1 to manipulate settings)
MOVLW b'0000000' ;mpve zeros to working
MOVWF PORTB ;then move them to portb statuses (mening output)
MOVLW b'111' ;set this to working
MOVWF PORTA ;then set porta to input
BCF STATUS,5 ;set the 5th bit of status register to zero (this transfers us to Bank 0 to manipulate values)
REDO
CLRF PORTB ; set all zeros to portB
movlw 0xFF ;First put the value of b255 in the W register
movwf COUNT1 ;Now move it to our 08h register.
movlw 0x2 ;First put the value of b2 in the W register for the second count (so it will be 255 x 2 = 510)
movwf COUNT2 ;Now move it to our 09h register
Loop2
decfsz COUNT1,1 ;Subtract 1 from 255
goto Loop2 ;If COUNT is zero, carry on.
decfsz COUNT2,1 ;Subtract 1 from 255
goto Loop2 ;Go back to the start of our loop.
MOVLW b'1111111'
MOVWF PORTB
movlw 0xFF ;First put the value of b255 in the W register
movwf COUNT1 ;Now move it to our 08h register.
movlw 0x2 ;First put the value of b2 in the W register for the second count (so it will be 255 x 2 = 510)
movwf COUNT2 ;Now move it to our 09h register
Loop1
decfsz COUNT1,1 ;Subtract 1 from 255
goto Loop1 ;If COUNT is zero, carry on.
decfsz COUNT2,1 ;Subtract 1 from 255
goto Loop1 ;Go back to the start of our loop.
GOTO REDO
END
#################################################
---------- Post added at 18:50 ---------- Previous post was at 18:50 ----------
CIRCUIT:
###################################################################################
**broken link removed**
Uploaded with ImageShack.us