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.

Having problems getting my PIC16F877A to work.

Status
Not open for further replies.

ItsMike

New Member
Hello everyone.

I just got my self a PIC16F877A and some other parts and I'm trying to get the pic to light a LED as a test but it doesn't work.

I've built the following circuits:

**broken link removed**
And another **broken link removed**

It's the **broken link removed**.

I'm using PIC C compiler with this code (C/ASM view) :
Code:
CCS PCM C Compiler, Version 4.093, 5967         

               ROM used: 21 words (0%)
                         Largest free fragment is 2048
               RAM used: 6 (2%) at main() level
                         6 (2%) worst case
               Stack:    0 locations

*
0000:  MOVLW  00
0001:  MOVWF  0A
0002:  GOTO   004
0003:  NOP
.................... #include <16F877A.h> 
.................... //////// Standard Header file for the PIC16F877A device //////////////// 
.................... #device PIC16F877A 
.................... #list 
....................  
.................... #fuses HS,NOWDT,NOPROTECT,LVP 
.................... #use delay(clock=20000000) 
.................... void main() 
.................... { 
0004:  CLRF   04
0005:  BCF    03.7
0006:  MOVLW  1F
0007:  ANDWF  03,F
0008:  BSF    03.5
0009:  BSF    1F.0
000A:  BSF    1F.1
000B:  BSF    1F.2
000C:  BCF    1F.3
000D:  MOVLW  07
000E:  MOVWF  1C
.................... output_d(0xFF);  
000F:  CLRF   08
0010:  MOVLW  FF
0011:  BCF    03.5
0012:  MOVWF  08
.................... while(1) 
.................... { 
.................... } 
0013:  GOTO   013
.................... } 
0014:  SLEEP

Configuration Fuses:
   Word  1: 3FF2   HS NOWDT PUT NODEBUG NOPROTECT BROWNOUT LVP NOCPD NOWRT

After I program the pic nothing happens, I've connected a LED to RD2 and it doesn't light up. I've tested the led by connecting it to the power supply directly and it works.

Any idea what's wrong ?

PS- there were no errors when i programmed and verified the pic.


Thanks in advance,
Mike.
 
Last edited:
I don't understand your code too well ( is this done in asm?? or C code shown as asm?), but iv'e used the 16f877A.
So in your code do you set the TRISD register to output? and then toggle the correct PORTD/LATD bit? (if you don't set TRISD properly it will remain an input pin and you wont see anything as output...)

Also i see you are using a HS osc... did you connect it properly? just double check that and if nothing still let me know or comment your code snippets more, so I can reference the data sheet.
 
Last edited:
As you can see from the code, I'm using the CSS PCM C Compiler.
I wrote the program in C and I showed the view of mixed c and asm for clarity since the port output functions are built in the compiler.

The OSC is connected properly.

I'm starting to think the problem is with the programming connection, maybe the pic still thinks it is in programming mode and doesn't start running ?
Although MCLR has a pullup resistor.

I'm really confused here.

EDIT:
/FACEPALM
Damn it, I just noticed i used a 22uF cap instead of a 22pF for the osc.
I'm gonna look for a 22pF cap.

EDIT#2:
Yep, those damn caps.
Since I didn't have any 22pF caps I used an RC osc and it works.

Thanks.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top