Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problem using PIC16F84A

Status
Not open for further replies.

new_entry

New Member
Hi there...right now i'm doing my final year project of 'heartbeat monitor' using pic16f84A directly taken from KeithWilson/Projects/hemon.htm.
I already construct the circuit and already load the original hex code into pic but it didn't work.
The original code is based on PIC16F84, so my question is do i need to alter the code?I know it sounds pretty lame...but i'm new to the PIC programming.

if i can use the original code, i wonder WHY IT DIDN'T WORK?

aNYONE ESPECIALLY THOSE WHO ALREADY DONE THIS 'HEARTBEAT MONITOR' PROJECT....Please help me.... :cry:
 
I think you better stop and go back to the basics on this one first before doing anything else. By basics i mean have you checked the power, is the oscillator ticking when powered up? Buzz out your circuit and make sure no shorts exsit. The amout of times i have working on a project and convinced myself it was the code, only to find out something wasnt soldered properly. Issolate areas and work it up.
 
Yes, I've got the same problem with PIC. I compiled the HEX file and uploaded it into PIC. It doesn't work. There is no voltage (not even log. "0") on I/O ports. I checked the power of PIC and there is full 5 volts on VDD. Sure no shortcircuits exist. But still I'm not sure what's wrong. How can I find out if the crystal is working (ticking)? Can you help, please?

I am running PIC16F84A-04/P
 
satrapad said:
Yes, I've got the same problem with PIC. I compiled the HEX file and uploaded it into PIC. It doesn't work. There is no voltage (not even log. "0") on I/O ports. I checked the power of PIC and there is full 5 volts on VDD. Sure no shortcircuits exist. But still I'm not sure what's wrong. How can I find out if the crystal is working (ticking)? Can you help, please?

I am running PIC16F84A-04/P

You can use an oscilloscope on the crystal pins, be sure to use a x10 probe, or the capacitance of the probe often stops the oscillator anyway!.

You should also check that the MCLR (reset) pin is connected correctly!.

What do you have the config fuses set to?.
 
satrapad said:
Well, I checked the MCLR pin and it's set to "1" (5 volts).

Ehm, what do you mean by "config fuses".

The 'config fuses' are the internal settings for the processor, they select oscillator type and various other functions - they are also different for different types of PIC, so you need to ensure you set them correctly.

It's recommended by MicroChip (and by ME!) that you should include them in your source code, the assembler has specific directives for this reason (see '__config'). The assembler then includes them in the HEX file, and your programmer software should read them and set the PIC accordingly.
 
yes, there is a segment of code I found in reg16c84.inc (I wonder why it is called 16c84 if I am using 16f84a? Does it mater or is it similar?)


Code:
;configuation word register

;config	equ	$0fxff		;configuration word register
fosc0	equ	0x00		;oscillator select bit
fosc1	equ	0x01		;oscillator select bit
wdte	equ	0x02		;watchdog enable bit
cp		equ	0x03		;code protection bit

but this code is included in stand-alone file (reg16c84.inc), then there is the source code (hemon.asm) and then a file with PortA and PortB definitions (LED diplay)
 
satrapad said:
yes, there is a segment of code I found in reg16c84.inc (I wonder why it is called 16c84 if I am using 16f84a? Does it mater or is it similar?)


Code:
;configuation word register

;config	equ	$0fxff		;configuration word register
fosc0	equ	0x00		;oscillator select bit
fosc1	equ	0x01		;oscillator select bit
wdte	equ	0x02		;watchdog enable bit
cp		equ	0x03		;code protection bit

The MicroChip include file is called P16F84A.INC, you shouldn't be using a 16C84 one, they are NOT the same!.

But that file doesn't sound like a MicroChip include file at all?, they don't look like that, they are installed as part of MPLAB along with MPASM the assembler.
 
Okey, now I changed the include file reg16c84.inc into p16f84a.inc and changed the name of include file in hemon.asm. But there is another problem. When I build the HEX file it is thoroughly similar as the old HEX file I've built before. I do not understand that...

And after the compiling the compiler shows me two messages:

Message[302] E:\HEARTB~1\HEARTB~1\HEARTB~1\HEARTB~1\HEMON.ASM 77 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] E:\HEARTB~1\HEARTB~1\HEARTB~1\HEARTB~1\HEMON.ASM 79 : Register in operand not in bank 0. Ensure that bank bits are correct.

Code:
;****************************************************************
;Name		: Initialisation
;Description	: system initialisation and mainloop
;Inputs		: none
;Outputs	: none
;****************************************************************
Initialisation:

;system initialisation

;port A and port B initialisation

	bcf	STATUS,RP1		;select bank1 register
	bsf	STATUS,RP0

	movlw	PORTA_CONFIG1		;PORTA configuration
	movwf	TRISA			;77!!!!!!!
	movlw	PORTB_CONFIG1		;portb configuration
	movwf	TRISB                           ;79!!!!!!

	bcf	STATUS,RP0		;select bank0 registers

	movlw	0x00			;disable all displays
	movwf	PORTA
 
satrapad said:
Okey, now I changed the include file reg16c84.inc into p16f84a.inc and changed the name of include file in hemon.asm. But there is another problem. When I build the HEX file it is thoroughly similar as the old HEX file I've built before. I do not understand that...

There appears to be no configuration fuse settings in the source code, so you will either have to add them, or set them in your programmer software before you program the PIC. However, there doesn't appear to be any mention of what they should be?.

I would suggest you try setting it as "__config 0x3FF9", check where this goes from my tutorials - without setting the config fuses it will default to RC oscillator, and NOT XT, so it can't work.
 
Thank you, I compiled the asm file with "__config" and it seems to be different than the old one. I'll try if it works...

thanks a lot
 
Hello again!
Today I programmed the P16F84A and step before I added the "__config 0x3FF9" code into asm file as Nigel Goodwin adviced me. IT WORKS PERFECTLY!!!

So thank you again Nigel very much!!!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top