LIST P=16F877A
#include <p16f8477.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC
org 0x0000
bsf STATUS, RP0
movlw 0x00
movwf TRISC
movwf TRISD
bcf STATUS, RP0
movlw 0xff
movwf PORTC
movwf PORTD
end
the code is clean and running in proteus, but when i program it in my pic16f877a its not functioning..doesn't even output logic 1.. vdd/vss are connected correctly..but no reading from the output ports.. I can read/write in my pic..i think its not broken..I even tested it to output 2 ports.. still no output..can't even lit an LED.. what could be possible wrong?
here's my program for outputting the 2 ports:
Code:LIST [COLOR=Blue] P=16F877A[/COLOR] [COLOR=Red] #include <p16f8477.inc>[/COLOR] __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC org 0x0000 bsf STATUS, RP0 movlw 0x00 movwf TRISC movwf TRISD bcf STATUS, RP0 movlw 0xff movwf PORTC movwf PORTD end
LIST P=16F877A
#include <p16f877A.inc>
errorlevel -302 , -207 ; suppress message 302 from list file
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _[COLOR="Red"]RC[/COLOR]_OSC
CounterA equ 0x20
CounterB equ 0x21
CounterC equ 0x22
org 0x0000
bsf STATUS, RP0
movlw 0x00
movwf TRISC
movwf TRISD
loop1:
bcf STATUS, RP0
movlw 0xff
movwf PORTC
movwf PORTD
call delay1
movlw 0x00
movwf PORTC
movwf PORTD
[COLOR="Red"] call delay1[/COLOR]
goto loop1
;PIC Time Delay = 0.50000200 s with Osc = 4000000 Hz
delay1:
movlw D'3'
movwf CounterC
movlw D'138'
movwf CounterB
movlw D'85'
movwf CounterA
loop decfsz CounterA,1
goto loop
decfsz CounterB,1
goto loop
decfsz CounterC,1
goto loop
retlw 0
end
;Tutorial 1.2 - Nigel Goodwin 2002
LIST p=16F628 ;tell assembler what chip we are using
include "P16F628.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the configuration settings (oscillator type etc.)
cblock 0x20 ;start of general purpose registers
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
endc
org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
;this is where the program starts running
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PortB all outputs
movwf TRISB
movwf TRISA ;set PortA all outputs
bcf STATUS, RP0 ;select bank 0
Loop
movlw 0xff
movwf PORTA ;set all bits on
movwf PORTB
nop ;the nop's make up the time taken by the goto
nop ;giving a square wave output
call Delay ;this waits for a while!
movlw 0x00
movwf PORTA
movwf PORTB ;set all bits off
call Delay
goto Loop ;go back and do it again
Delay movlw d'250' ;delay 250 ms (4 MHz clock)
movwf count1
d1 movlw 0xC7
movwf counta
movlw 0x01
movwf countb
Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0
decfsz count1 ,f
goto d1
retlw 0x00
end
Woops!, too quick on the keyboard today, missed that 2nd delay!!...
sorry sir! i posted the wrong code..didn't notice it right away..anyway, you corrected it..thats pretty helpful sir nigel! but i don't have an xtal osc right now..i only have a couple of led..resistors..and the pic to test the ports..a simple output 1 will to lit the leds will do..
how did you know that my program is set to use a 20MHz oscillator sir? how i could set it to 4MHz? actually, i just took the worksheet from unknown program and edit the contents.. thank you!
sorry sir! i posted the wrong code..didn't notice it right away..anyway, you corrected it..thats pretty helpful sir nigel! but i don't have an xtal osc right now..i only have a couple of led..resistors..and the pic to test the ports..a simple output 1 will to lit the leds will do..
if i use a 4MHz xtal osc and a 22pF capactor(2)..will it be ok sir? thank you!
thank you sir!! in that way sir, i dont have to add the 4MHz xtal and cap? or i still should? will it be ok now without the xtal sir?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?