# strange 16f84a

Status
Not open for further replies.

#### ProFPGA

##### Banned
hi all,

i have programmed a 16f84a with simple routine to light up three leds on RA2,3 and 4, with a delay of 2.50sec ( with a 4mhz cystal ). it programmed well .

I have also tied MCLR to pull-high resistor .
but it doesnt run , only when i pull the vcc wire out of bread brd and touch it again the LEDS blink and turn off.

here's the code :

list p=16F84A
;Specifying SFRs
status equ 03
porta equ 05
trisa equ 05
portb equ 06
trisb equ 06
delcntr1 equ 11
delcntr2 equ 12

org 00
;Initialise
start bsf status,5 ;select bank 1
movlw B'11111111'
movwf trisb ;portb bits 0-7 input
movlw B'00000'
movwf trisa ;porta bits all outnput
bcf status,5 ;select bank 0
clrf porta
loop movlw B'00010000'
movwf porta
call delay
call delay
movlw B'00001000'
movwf porta
call delay
call delay
movlw B'00000100'
movwf porta
call delay
call delay
goto loop

;Introduces delay of 1.25sec approx, for 1 MHz clock
delay movlw D'250'
movwf delcntr2
outr movlw D'250'
movwf delcntr1
innr nop ;10 inst cycles in this loop
nop
nop
nop
nop
nop
nop
nop
nop
nop
decfsz delcntr1,1
goto innr
nop ;10 inst cycles in this loop
nop
nop
nop
nop
nop
nop
nop
nop
nop
decfsz delcntr2,1
goto outr
return
;-----------------------
end

any clues ????

#### Nigel Goodwin

##### Super Moderator
Most Helpful Member
For a start use the MicroChip supplied INC file, don't define them yourself, also use them for setting status bits etc. I've no idea if you're setting anything correctly, as you're not using the supplied names.

Also, when posting code, use the 'Code' tags to surround it, this keeps the formatting of the code - there's a button on the 'Go Advanced' screen.

#### birdman0_o

##### Active Member
I'm pretty sure you defined trisA & trisB. Actually now I'm sure after checking the datasheet. They are 085h and 086h respectively. By the way they should all be followed by an h, otherwise the compiler thinks it is in decimal.
Try this for a starter.
Oh and
Code:
Org 0x00
Goto Start
Org 0x04
Goto Start

#### birdman0_o

##### Active Member
Also do you have something like this at the top of your code???

Code:
	list	p=16f84A,f=inhX32
#include <p16f84A.inc>
__config _CP_OFF & _WDT_OFF

+ Why are you using the outdated 84a instead of something more modern?

Last edited:

#### Nigel Goodwin

##### Super Moderator
Most Helpful Member
I'm pretty sure you defined trisA & trisB. Actually now I'm sure after checking the datasheet. They are 085h and 086h respectively. By the way they should all be followed by an h, otherwise the compiler thinks it is in decimal.

The 085h is only an instruction to the assembler, 005h works just as well, and is the value actually produced by the assembler. You obviously only need the 'h' for hexadecimal if the value is greater than 9, and even then only if you don't have the default radix set as hex.

But use the include file as you're supposed to, and such things don't matter.

#### birdman0_o

##### Active Member
What is the default radix because he used 11 and 12, without specifying hex.

#### Nigel Goodwin

##### Super Moderator
Most Helpful Member
What is the default radix because he used 11 and 12, without specifying hex.

The default radix is whatever you set it to, either in the program (which is another part he's left out), or in the assembler itself - where you can select 'Default' (source code tells it what to use). Hexadecimal, Decimal, or Octal (these over write the source code setting).

As 11 and 12 are only GPR's it doesn't make any difference anyway.

Last edited:

#### birdman0_o

##### Active Member
From the looks of it, 11 dec is 0Bh which is INTCON, which would mess with things no? 12 is a GPR weither HEX or dec.

#### Pommie

##### Well-Known Member
Most Helpful Member
Luckily (for the OP) the default radix is hexadecimal.

Mike.

#### birdman0_o

##### Active Member
You will need to set portA, pin5 as input, you set it as output.

#### ProFPGA

##### Banned
solved

the problem is solved ,,,,
it was in configuration bits , instead of specifying XT oscillator , i selected
LP .

It works now

its funny though pulling vcc wire out and back in could create some pulses thus making it work. ( a point to be noted )

i am using 16f84a as a learning platform , i will advance myself later .

#### Nigel Goodwin

##### Super Moderator
Most Helpful Member
i am using 16f84a as a learning platform , i will advance myself later .

It's not a question of 'advancing', just that the 16F84 was obselete last century, and while it's been reintroduced (presumably to make huge profits) it's lower spec, harder to use, and more expensive than the 16F628 which replaced it.

#### ProFPGA

##### Banned
well , thats a news flash for me .
actualy i was following that book "designing embedded systems using PIC microcontrollers" , it discusses 16f84 in the begining.

#### Nigel Goodwin

##### Super Moderator
Most Helpful Member
well , thats a news flash for me .
actualy i was following that book "designing embedded systems using PIC microcontrollers" , it discusses 16f84 in the begining.

What copyright date is the book? - presumably 19 something?.

Last edited:

#### birdman0_o

##### Active Member
Even some books in the 2000's use the pic16f84...maybe because they assume they are easier to get or that there was more online support at the time?

#### Nigel Goodwin

##### Super Moderator
Most Helpful Member
Even some books in the 2000's use the pic16f84...maybe because they assume they are easier to get or that there was more online support at the time?

Very poor books if they do!

#### birdman0_o

##### Active Member
"Micro chips for dummies" lol

#### ProFPGA

##### Banned
just a thought , i dont see any C code examples for 16f84a ???
r there any ?

Last edited:

#### Nigel Goodwin

##### Super Moderator
Most Helpful Member
just a thought , i dont see any C code examples for 16f84a ???
r there any ?

Very few, why would they be?.

#### birdman0_o

##### Active Member
There will only be examples if people haven't updated their website since the last century and have kept it hanging around. Perhaps there are some examples lingering on this site still.

Status
Not open for further replies.

Replies
5
Views
1K
Replies
4
Views
2K
Replies
17
Views
20K
Replies
9
Views
5K
Replies
25
Views
9K

Loading