Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[moved] Pic 16F84A doesnt give any output

Status
Not open for further replies.

myeou

Newbie level 3
Joined
May 8, 2016
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
30
hi , i am trying to learn pic programming and basic circuit. So i am unexperienced. I am using pic16f84a with 4 mhz crystal osillator with 22pf capacitor. Circuit runs on 5 V with 7805 regulator. and this is the code:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <16F84A.h>
 
#define pir input(PIN_A2) // Switch on RA0
 
void main (void)
{
set_tris_a(0x11); 
set_tris_b(0x00); 
output_b(0x00);
 
while(1) { //Forever Loop
output_high(pin_B1);
output_high(pin_B2); 
}
}



I import this file with pickit2.
There voltage supply on pic , i can read it with voltameter but somehow there is no output. It isnt work.
Anyone , any idea how to solve the problem ?
 
Last edited by a moderator:

Have you configured 'configuration bits properly?. Don't forget to connect a pull up resistor on mclr pin.
 

hi , i am trying to learn pic programming and basic circuit. So i am unexperienced. I am using pic16f84a with 4 mhz crystal osillator with 22pf capacitor. Circuit runs on 5 V with 7805 regulator. and this is the code:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <16F84A.h>
 
#define pir input(PIN_A2) // Switch on RA0
 
void main (void)
{
set_tris_a(0x11); 
set_tris_b(0x00); 
output_b(0x00);
 
while(1) { //Forever Loop
output_high(pin_B1);
output_high(pin_B2); 
}
}



I import this file with pickit2.
There voltage supply on pic , i can read it with voltameter but somehow there is no output. It isnt work.
Anyone , any idea how to solve the problem ?


I only coded the pic16f84a with micro C before ,
in order to be able to get voltage out you only need to put the TRIS in the output mode,
then give the pin in the PORT a 1 which is what you did. seems perfect.
can you take a picture of the circuit, I ll try to look up that language you are using.
because it look like I know a different C language here.
but a picture of your circuit would be helpful to spot if something is wrong.
 

Did you try with any of the sample programs? Is the oscillator up and running? Are you setting up the correct pins for digital in/out mode (as applicable)? The forever loop (lines 12 and 13) will make the pins B1 and B2 high but how you are setting them up?
 

Well i added a 10 k resistor and supply voltage to the MCLR pin. BUt ı dont know how to set the configurations bits. Is it something that i should add to the code or something that is hould enable while writing the hex to the pic ( i am using pcikit 2 for this btw. )

Code is for test. It only should light up the leds forever. But it doesnt.
Weird thing , i am using 7.5 V adapter to supply votlage . When i wiggle the adapter in its socket , there is a very little light that appears in the led. But onyly when i wiggle it.

I check the voltage in the pins of the pic with multimeter. There is voltage supply , i can read it .So supply is coming to the pic for sure. But there is no output votlage in the pins. There is not any output voltage any of the pins ...

- - - Updated - - -

ok i find out how to configure bits. Here is the new code.

Code:
#include <16F84A.h>
#define pir    input(PIN_A2)  // Switch on RA0
#fuses XT         //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#fuses PUT        //Power Up Timer
#fuses NOWDT      //No Watch Dog Timer


void main (void)

{
set_tris_a(0x11);
set_tris_b(0x00);
output_b(0x00);



     
int16 delay;
delay=0;
while(1) { //Forever Loop
if(delay>=0 && delay < 10000 ){

output_high(pin_B1);
output_high(pin_B2);
delay+=1;

}
if(delay>=10000 && delay < 20000){

output_low(pin_B1);
output_low(pin_B2);
delay+=1;
}
if(delay==20000){delay=0;}

}

}

It actually worked... but partially. The new problem is leds are light up. But the light is too weak.
I checked on voltage with multimeter on pins and the output voltage is very unstable.
It goes like 4.00 , 0.10 , 2.12, 3.45 in a second .

Why is this happening ? How can i make it stable ?
 

Are the two pins B1 and B2 configured correctly for digital output?
 

Not an answer to your question but a comment on your programming approach.
The device you are using has 1024 words of program memory and so you need to think about your code and be efficient in what you write.
Looking at the call you have to set the TRISB register to all zeros. You write this as 'set_tris_b(0x00);' which is a function call. The call itself will take 1 program work for the call itself and one for the return statement. There will also be code to set up the parameter that is passed and also within the function itself to retrieve it. Then there is the command to set the TRISB register. At best that will be 4 to 5 instructions.
The alternative is to move a literal value to W which is 2 code words (or use the CLR instruction which is 1 code word) and then move W to TRISB - a total of 2 or at most 3 program words.
While this might not sound a lot, when you only have 1024 words to start with and you do something like this 7 times just in your small test program, the wastage can add up.
My suggestion is to access the SFRs directly when it is appropriate (and for most of what this chip can do, it will be appropriate) and not try to use function calls.
Susan
 
It actually worked... but partially. The new problem is leds are light up. But the light is too weak.
I checked on voltage with multimeter on pins and the output voltage is very unstable.
It goes like 4.00 , 0.10 , 2.12, 3.45 in a second .

Why is this happening ? How can i make it stable ?

You did add the resistors in series with the LED (say 220R)? You did add decoupling capacitors to the supply rails? ( A 0.1uf ceramic as close to the supply pins as possible, and a bulk electrolytic capacitor of 10uF or greater.) You have checked the power supply rails are stable and can supply the current required by the LED's?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top