help on using 16f84

Status
Not open for further replies.

mikelim

New Member
Hi there,
I am new on pic and I have troubles on getting my 16f84 to work. I wrote this simple basic program.

1. I used this free basic compiler and wrote the following. It should get the various indicated pins to be high / low. I wrote this delay subroutine but eventually remarked it out as I cannot even get the pins voltages correct.

_______________________________


bitset(rp0)
trisa=0
trisb=0
bitclear(rp0)

main:
ra.0=1
ra.1=1
ra.2=1
ra.3=1

rb.0=1
rb.1=1
rb.2=0
rb.3=1

'goto main:

'rem delay routing of 1.2s
'delay: i=200
' i2=200
' i3=10
' while i3>0
' while i2>0
' while i>0
' decr
' wend
' wend
' wend
'
' return

interrupt:

2. after using picbas, which is a free basic compiler, i obtained the following assembly code.

_______________________


include 'c:\pictools\16f84a.inc'
FUSES _XT_OSC
FUSES _WDT_OFF

DEVICE pic16c84,XT_OSC,WDT_OFF
org 0
JMP CC0
org 4
jmp INTERRUPT
CC0
; bitset(rp0)
setb RP0
; trisa=0
mov w,#0
mov 5,w
; trisb=0
mov w,#0
mov 6,w
; bi
jay says:
; bitclear(rp0)
clrb RP0
;
; main:
MAIN
; ra.0=1
mov w,#1
mov 13,w
; ra.1=1
mov w,#1
mov 14,w
; ra.2=1
mov w,#1
mov 15,w
; ra.3=1
mov w,#1
mov 16,w
;
; rb.0=1
mov w,#1
mov 17,w
; rb.1=1
mov w,#1
mov 18,w
; rb.2=0
mov w,#0
mov 19,w
; rb.3=1
mov w,#1
mov 20,w
;
; 'goto main:
;
; 'rem delay routing of 1.2s
; 'delay: i=200
; ' i2=200
; ' i3=10
; ' while i3>0
; ' while i2>0
; ' while i>0
; ' decr
; ' wend
; ' wend
; ' wend
; '
; ' return
;
; interrupt:
INTERRUPT
;

_____
(in it, i had too disable watchdog, i selected xt as i am using a 4mhz crystal.)

3. i then burnt in the machine code after assembling the above machine code using a jdm programmer/ and ic-prog

4. the circuitry connected to my 16f84a is as follows

pin 4 - a 20k resistor to 5V
pin 5 - 0V ref
pin 15 / 16 - a 4mhz crystal across
pin 15 - a cap to gnd 22pF
pin 16 - a cap to gnd 22pF
pin 17 - 5v

please help /advise.
thank you.

mike
 
mikelim said:
pin 15 / 16 - a 4mhz crystal across
pin 15 - a cap to gnd 22uF
pin 16 - a cap to gnd 22uF
pin 17 - 5v

If this is correct it won't work, the two capacitors should be 22pF, not 22uF.
 
HMM... mistake... the cap that i had used. is 22pF

Sorry, but i instead used 22pF cap. Typed wrongly. Please help, more advise, please.
 
additional info on my query

I am using cvasm16 assembler.
and i using a 4Mz crystal.
i was reading thru the cvasm16 a moment again.

____

;=======================================
; Configuration (FUSE) BIT Definitions
;=======================================
_CP_ON EQU 000Fh
_CP_OFF EQU 3FFFh
_PWRTE_ON EQU 3FF7h
_PWRTE_OFF EQU 3FFFh
_WDT_ON EQU 3FFFh
_WDT_OFF EQU 3FFBh
_LP_OSC EQU 3FFCh
_XT_OSC EQU 3FFDh
_HS_OSC EQU 3FFEh
_RC_OSC EQU 3FFFh

___
in my ass code i had fused _xp_osc & _wdt_off.

what should i do abt cp and pwrte ? what are they?
am i missing or mishandling any configuration bits or?
 
_xt_osc fuse is ok for 4MHz xtal, and _wdt_off also for what you are doing now.

I suggest you first of all verify the code written on your pic with IC-PROG (there is verify button on top, use that after programming), if verify fails you have a problem with the programmer.

If verify is ok then start to debug the circuit in which you run the PIC, there might be shorts or broken connections. I usually start from verifying the oscillator, if you have an oscilloscope see on pin 15 and 16 if the clock is running. If you don't have one use a tester, most of digital ones will show a bit over 2v on the clock pins (at 5v supply) if the clock is running, dead zero or almost 5v if stopped.
 
thanks guys

thanks guys.
i managed to find out my mistake.
it is a software prob.
or else my assumption
ahahha

=)
thanks ..
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…