PDA

View Full Version : problem with i/o pic16F876



mikmac
- 27th July 2010, 14:48
HI,
I'm in troubles here. I have programmed an pic16F876 to blink an LED.
I tried many ways to do it but the LED just blink a few times.
I don't know why. I tried to do this with proteus and just work fine but
in practice it didn't work.

In same way, I tried with pic16F627 and it worked fine, I don't understand
the difference for the two devices. Maybe in I/O hardware, I saw a few
differences in datasheet, but how can I do it?

Image from proteus : circuit_Proteus.jpg

I'm using CCS C with MPLAB 8.43


----------------------------------------------
C code

#include <16F876.h>
#FUSES XT,NOWDT,NOPROTECT,NOBROWNOUT,NOPUT
#use delay(clock=4000000)

void main()
{

SET_TRIS_B(0x00);

for( ; ; ){
OUTPUT_B(0x01);
delay_ms(500);
OUTPUT_B(0x00);
delay_ms(500);}
}

----------------------------------------------
hex code

:1000000000308A0019280000223084008313000881
:10001000031918280130F800F701F70B0D28F80B29
:100020000C284A30F700F70B13281628800B0A28F3
:100030000034840183131F30830583161F149F141B
:100040001F159F1100308600860101308312860043
:100050000230A100FA30A2000420A10B2A28831646
:100060008601831286010230A100FA30A20004202A
:0A007000A10B352883162428630035
:02400E00393F38
:00000001FF
;PIC16F876


----------------------------------------------

I already tried pullups, didn't work :(

Could anyone give me some help, please!

aratti
- 27th July 2010, 18:58
You have to pullup with a 10K resistor pin 1 (MCRL) otherwise mcu will not work.

Al.

mikmac
- 28th July 2010, 00:09
Just like that! I was looking many places but not
on right terms. I did not get it without your help.
When I did it, it has worked absolutely fine.

-> pullup MCRL with a 10K resistor pin 1

Many thanks, Aratti

malc-c
- 28th July 2010, 14:38
Just goes to show you can't always trust simulators.

Golden rules:
1) - Place a 0.1uF capacitor across the Vcc and Vdd lines as close to the PIC as you can. If the PIC has 2 sets of supply pins use a capacitor across each set of pins
2) - Use a pull up resistor between MCLR and +ve.
3) - Tie all inputs to either +ve or GND via pull up or pull down resistors - typically 1K - 10K - Not advisable to leave inputs floating