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.

Pic microcontroller not giving any response.no output at all.plz help

Status
Not open for further replies.

mugheesnawaz

Member level 1
Joined
May 1, 2013
Messages
39
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,605
i am using pic 16f877a for my project and i am using very basic code to get 5V on certain pins,i am using 20Mhz crystal and two 22pF capacitors.i am giving +5v on VDD and gnd on Vss and giving +5V on MCLR.but i dont get any output at all.plz help.i have set the oscillator to HS as i am using 20Mhz crystal.maybe my crystal isnt working how do i verify if its working or not? i am using mplab.i have read on forums about giving 13V to MCLR? is it true? i am giving 5V as of now.



Untitled.png

Code:
#include <htc.h>
#define _XTAL_FREQ 20000000
void main()
{
  TRISD=0;
  while(1)
  { 
   RD2=0;
RD3=1;
RD4=0;
  }
}
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
MCLR should be pulled up to 5V using 10k resistor. How is config bits set ? In IDE ?
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,878
Helped
4,862
Reputation
9,742
Reaction score
4,643
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
126,641
NEVER put 13V on MCLR for normal use. It puts the PIC into programming mode so it should only be used by your programming equipment to load the code into the IC. At any other time it is quite likely to corrupt the program. You should have it pulled to 5V (or whatever VDD voltage you use) so the PIC is taken out of reset state.

You should also have decoupling capacitors across each pair of power pins.

Brian.
 

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,249
Helped
377
Reputation
754
Reaction score
375
Trophy points
83
Activity points
13,524
Just a note: defining the _XTAL_FREQ symbol does nothing unless you also use the various _delay macros. It does not in any way set the oscillator configuration.
To check whether the oscillator is working you could use a scope (assuming it has a high enough impedance).
However, if you are using MPLAB, then use the debug mode and single step your way through the code. If the oscillator is not working then the device will not respond to the debugger; if it is then you will be able to step your way through the program.
You might be getting caught by the RMW problem that can occur in devices that don't have the 'LAT' registers (as the later Microchip devices do). Try setting the whole of the PORTD register at once (and it does not need to be within the main loop) rather than various bits at a time. Also try setting more pins to '1' - the the moment you are only setting PORTD bit 3 to logical 1 (whereas the beginning of your post uses "pins" plural).
Susan
 

MUKESH.K.S

Full Member level 1
Joined
Jan 31, 2014
Messages
98
Helped
14
Reputation
28
Reaction score
13
Trophy points
8
Location
KERALA
Activity points
607
You can set the configuration bits like this


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <htc.h>
#ifndef _XTAL_FREQ
#define _XTAL_FREQ 20000000
#endif
__CONFIG(FOSC_HS & WDTE_OFF& PWRTE_OFF & BOREN_OFF &
LVP_OFF & WRT_OFF & DEBUG_OFF & CPD_OFF & CP_OFF);
void main()
{
  TRISD=0;
  while(1)
  { 
   RD2=0;
RD3=1;
RD4=0;
  }
}

 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top