EmbeddedRelated.com
Forums

Help. PIC16F874A board not working at all

Started by chess September 10, 2005
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<----8<-
	ORG	00
START                   ; POWER_ON Reset (Beginning of program)
    CLRF    STATUS      ; Do initialization (Bank 0)
    MOVLW   0x00        ; Specify value for PortB output latch
    MOVWF   PORTB       ;
    BSF     STATUS, RP0 ; Bank 1
    MOVLW   0x00        ; Specify which PortB pins are outputs
    MOVWF   TRISB       ;
    BCF     STATUS, RP0 ; Bank 0
                        ;
lzz
    BSF     PORTB, 0    ; B0 is High
    BCF     PORTB, 5    ; B5 is Low
    GOTO    lzz         ; Loop
--8<----8<-


I am still suspicious about the reset circuit, but have no idea what to
do. We didn't tested
Power-up Timer (PWRT) yet.

I need to know
1. Is reset really hard in PIC? I mean, RC reset circuit is very
simple. Moreover, several
   PIC books suggest just to tie-up /MCLR to VDD without any reset
circuit. We tried both
   and still not seems it working.
2. If PIC reset, how can i know that? Without any programm loaded, what
is the I/O pins' status
   when i probe them?
3. When programming, is it need special configuration for PIC16f874a? I
used ALL-100 programmer.
   When i firstly programmed it using default setting and just
selecting devcie as PIC16f874a, it
   didn't write the program at all! It just passed
erase/blanktest/program/veryfy/protection. But when
   read the contents, it is still blank!. So I turned off protection.
After that, it seems writing correctly.
   Do i missing something using this programmer?

Any suggestions?

Thanks in advance.

-chess

chess wrote:
> 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.
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
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

chess wrote:
> 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.
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
Hi.

> 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.
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
Dear chess,

chess schrieb:
> 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.
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.
> I need to know > 1. Is reset really hard in PIC? I mean, RC reset circuit is very > simple. Moreover, several > PIC books suggest just to tie-up /MCLR to VDD without any reset > circuit. We tried both > and still not seems it working.
For a test circuit, tieing MCLR to Vdd is okay.
> 2. If PIC reset, how can i know that? Without any programm loaded, what > is the I/O pins' status > when i probe them?
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.
> 3. When programming, is it need special configuration for PIC16f874a? I > used ALL-100 programmer. > When i firstly programmed it using default setting and just > selecting devcie as PIC16f874a, it > didn't write the program at all! It just passed > erase/blanktest/program/veryfy/protection. But when > read the contents, it is still blank!. So I turned off protection. > After that, it seems writing correctly. > Do i missing something using this programmer?
Yes. You didn't set the configuration bits. HTH Wolfgang -- From-address is Spam trap Use: wolfgang (dot) mahringer (at) sbg (dot) at
Dear Wolfgang,

Thank you for you reply.

My trial code has  __CONFIG set as _RC_OSC. I didn't knew the meaning
of 
__CONFIG at all.

- chess

Dear Michael,

Thank you for your reply. The code should be revisited when I fix the
problem.

-- chess

Hi chess,

chess wrote:

> My trial code has __CONFIG set as _RC_OSC. I didn't knew the meaning > of __CONFIG at all.
OK, did you connect the RC circuit then? Which values? Does it oscillate when powered on? HTH Wolfgang -- From-address is Spam trap Use: wolfgang (dot) mahringer (at) sbg (dot) at
chess schrieb:

> My trial code has __CONFIG set as _RC_OSC. I didn't knew the meaning > of > __CONFIG at all. >
In the 1st post you write, there is an XTAL connected. That will not work if you set the RC osc mode! As I described in another post, you should disable something else, to prevent some mantraps. So you should something more specified: __CONFIG _LVP_OFF & _BODEN_OFF & _PWRTE_ON & _WDT_OFF & _HS_OSC This disables low-voltage programming, brown-out reset, watchdog, and enables the power-up timer and the high-speed xtal/resonator mode. All ohter bits, not specified here, are set to '1' because of the macro structures. Please(!) read the manual. Michael