Help. PIC16F874A board not working at all

Hi,

My friend is working his embedded board with PIC16f874a. I just programmed it to ON or OFF port B. But not working at all. All I/O pins seem to stay in high-impedance.

The board layout is very simple. It only had Powersource and XTAL circuit. Later we added RC reset circuit just because we were not sure whether it RESET properly, but it was useless.

Progam code is:

--8

Reply to
chess
Loading thread data ...

If this is a breadboard design, are you sure the oscillator starts running properly?

I'd first configure the PIC to use an external RC osc, disable WDT, and enable power-up reset timer (no external reset connected). After programming and removing the programmer, you can watch the R&C voltage with an oscilloscope, see if it runs...

Also are you sure the ALL-100 really supports the PIC16f874A? (correct config word etc)

- Jan

Reply to
Jan Wagner

Thank you. It is designed on universal printed circuit board. I just used a crystal and two capacitors for the oscillator circuit. ALL-100 supports PIC16f874a, but I'm not sure whether the default configuration is working. As I said, the default configuration performed PROTECTION as its last process. But when I checked again (by reading or comparing the contents), I just found nothing was actually written. After I tried without protection, code seemed been written correctly.

- chess

Reply to
chess

When you enable "code protection", this means you can't read it back from the chip. So what you saw is ok. That's the point of code protection :-)

- Jan

Reply to
Jan Wagner

Hi.

Some suggestions: AFAIK "protection" means code protection, so you don't see, what's written. It's not so easy handling, if you enable code protection (CP) while programming. If some start problems, it's generally a good idea to minimize the configuration, simplest OSC mode (internal or RC), no watchdog, no brown-out, no MCLR if possible, debug off and power-up timer on.

To your code: It is a bad thing, to manipulate bits on the i/o ports with bsf/bcf/and/or/ ..., because all operations are read-modify-write operations. So if you change one bit, some others can be influenced from external. For example in your code, if B0 is connected with a resistor to ground, the next operation on B5 will also set B0 to low. Therefore I recommend, to change the bits in a other register and write the whole byte to the port register. In the next generation PIC (18F) there is a special register (LATx), to prevent this case.

HTH Michael

Reply to
Michael Lange

Dear chess,

chess schrieb:

Your code does not contin any configuration register settings. See __CONFIG command and the processors datasheet. Since most assemblers set all the config bits 1 by default, you select RC oscillator mode, which is probably not what you want.

For a test circuit, tieing MCLR to Vdd is okay.

Using a scope, watch pins OSC1/CLKIN and OSC2/CLKOUT. If the PIC is running, you'll notice an oscillation on at least one of these pins.

Yes. You didn't set the configuration bits.

HTH Wolfgang

--
From-address is Spam trap
Use: wolfgang (dot) mahringer (at) sbg (dot) at
Reply to
Wolfgang Mahringer

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.