Hello, I'm using PIC16F876 with PCM (from CCS) C-Compiler.
I put the Prescaler from the timer 0 to the Watch Dog because timer 0 is
lead externally and has to be incremented at each falling edge. I put NOWDT
on the configuration bits. in spite of those elements the PIC resets because
of the WDt.
Please, how can i solve it.
____________________
Samuel BOUQUET
Sociiti INOV'TRONIK
8/10 rue Emile Sehet
ZA des chataigniers
95150 Taverny
____________________
Tel: (33) 1 39 95 29 50
Fax: (33) 1 39 95 74 10spam_OUTs.bouquetTakeThisOuTinovtronik.com

> Hello, I'm using PIC16F876 with PCM (from CCS) C-Compiler.
> I put the Prescaler from the timer 0 to the Watch Dog because timer 0 is
> lead externally and has to be incremented at each falling edge. I put NOWDT
> on the configuration bits. in spite of those elements the PIC resets because
> of the WDt.

Can you post your #FUSES line and the code you're using to set up TIMER0 and
the prescaler?

> Hello, I'm using PIC16F876 with PCM (from CCS) C-Compiler.
> I put the Prescaler from the timer 0 to the Watch Dog because timer 0
> is lead externally and has to be incremented at each falling edge. I
> put NOWDT on the configuration bits. in spite of those elements the
> PIC resets because of the WDt.

I've used NOWDT in CCS with the F876 and it works fine. So:

- most programming software allows you to manually change the settings
of the configuration bits. Did the watchdog inadvertently get turned
on that way?
- Are you sure it's a watchdog reset? How do you know?
- are you using an emulator? With the ICE2000, for example, you change
the watchdog stuff via menu options - the settings in the hex file
don't have any effect.

> >Samuel BOUQUET <s.bouquetKILLspamINOVTRONIK.COM> said:
> >
> > Hello, I'm using PIC16F876 with PCM (from CCS) C-Compiler.
> > I put the Prescaler from the timer 0 to the Watch Dog because timer 0 is
> > lead externally and has to be incremented at each falling edge. I put
NOWDT
> > on the configuration bits. in spite of those elements the PIC resets
because
> > of the WDt.

>Dale Botkin said:
>
>Can you post your #FUSES line and the code you're using to set up TIMER0
and
>the prescaler?
>
>Dale

I read on a Microchip datasheet (Mid Range Reference Manuel, 33023.pdf) that
there are assemblary lines to get the PIC working on a good way (page 176).I
am working on it to try to get the timer working good. the WDT seems to be
stop with those instructions.

>Mike Mansheim said:
>> Hello, I'm using PIC16F876 with PCM (from CCS) C-Compiler.
>> I put the Prescaler from the timer 0 to the Watch Dog because timer 0
>> is lead externally and has to be incremented at each falling edge. I
>> put NOWDT on the configuration bits. in spite of those elements the
>> PIC resets because of the WDt.

>I've used NOWDT in CCS with the F876 and it works fine. So:

>- most programming software allows you to manually change the settings
> of the configuration bits. Did the watchdog inadvertently get turned
> on that way?
>- Are you sure it's a watchdog reset? How do you know?
>- are you using an emulator? With the ICE2000, for example, you change
> the watchdog stuff via menu options - the settings in the hex file
> don't have any effect.

My programmer is fine, i do not use an emulator.
I use timer0 with prescaler at 1:1. Microchip Datasheets explain that it
could activate the WDT, despite i don't use assemblary routine they
recommend to use in this case. when i use their routine, my timer0 don't run
anyway. I still working on it.

> I read on a Microchip datasheet (Mid Range Reference Manuel, 33023.pdf) that
> there are assemblary lines to get the PIC working on a good way (page 176).I
> am working on it to try to get the timer working good. the WDT seems to be
> stop with those instructions.

That procedure is needed when switching the prescaler between the WDT and
TIMER0, whether you have the WDT enabled or not. I think the problem is
occurring when you manually set OPTION_REG bit 3. What are you trying to
accomplish with that? This line:

setup_counters (RTCC_EXT_H_TO_L, RTCC_DIV_2);

will (safely) assign the prescaler to TIMER0, you don't need to do it
yourself. The compiler will use the corerct procedure to avoid the
problem noted in the midrange manual. Just delete the "bit_set
(OPTION_REG, 3)" statement and I think you'll be OK.

By setting the OPTION_REG bit 3 I put the prescaler to the WD. I need a 1:1
TIMER 0 in my application. So the bit PSA (OPTION_REG bit 3) has to be set.
But by setting it the prescaler goes to the WD. My problem is that it
generates a reset a short time after because of the WDT which should be
disabled.
So how can i get safely a timer 0 without prescaler and without an undesired
WDT-reset?

> I read on a Microchip datasheet (Mid Range Reference Manuel, 33023.pdf)
that
> there are assemblary lines to get the PIC working on a good way (page
176).I
> am working on it to try to get the timer working good. the WDT seems to be
> stop with those instructions.

That procedure is needed when switching the prescaler between the WDT and
TIMER0, whether you have the WDT enabled or not. I think the problem is
occurring when you manually set OPTION_REG bit 3. What are you trying to
accomplish with that? This line:

setup_counters (RTCC_EXT_H_TO_L, RTCC_DIV_2);

will (safely) assign the prescaler to TIMER0, you don't need to do it
yourself. The compiler will use the corerct procedure to avoid the
problem noted in the midrange manual. Just delete the "bit_set
(OPTION_REG, 3)" statement and I think you'll be OK.

> By setting the OPTION_REG bit 3 I put the prescaler to the WD. I need a
1:1
> TIMER 0 in my application. So the bit PSA (OPTION_REG bit 3) has to be
set.
> But by setting it the prescaler goes to the WD. My problem is that it
> generates a reset a short time after because of the WDT which should be
> disabled.
> So how can i get safely a timer 0 without prescaler and without an
undesired
> WDT-reset?

This sounds like another classic CCS bug to me. Several times I have
found that #fuses bits work backwards in some of their releases, right
now I have a project for the 'F73 that must use "NOPUT" to *enable* the
power up timer. A sheepish tech at CCS explained that they are working on
this after I wasted a couple of hours pulling out my hair..

Try enabling your WDT, I'll bet the WDT will then turn off. Or else,
upgrade to the version du jour.

At 12:24 PM 8/28/02 -0500, llileSTOPspamspam_OUTSALTONUSA.COM wrote:
>This sounds like another classic CCS bug to me. Several times I have
>found that #fuses bits work backwards in some of their releases, right
>now I have a project for the 'F73 that must use "NOPUT" to *enable* the
>power up timer. A sheepish tech at CCS explained that they are working on
>this after I wasted a couple of hours pulling out my hair..
>
>Try enabling your WDT, I'll bet the WDT will then turn off. Or else,
>upgrade to the version du jour.

Assuming the original poster is using a PS+, why not just look at the fuse
data when the file is loaded into the programmer?

> > Yes, but fiddling with the PSA bit can cause an unintended WDT reset even
> > if it's disabled, apparently.
>
> I find that *very* hard to believe. Do you have any solid evidence to
> support this belief?

Well, yes, otherwise I wouldn't have said it. As the OP noted, you can
look at section 11.6.1 on page 11-8 of DS31101A, the PIC Midrange
reference manual.

"NOTE: To avoid an unintended device RESET, the following instruction
sequence (shown in Example 11-1) must be executed when changing the
prescaler assignment from TIMER0 to the WDT. This sequence must be
followed even if the WDT is disabled."

I'd say that explains why he gets a WDT reset when he manually twiddles
PSA even though he's got the WDT disabled. I had to look it up to be
sure, but there it is plain as day.

> This sounds like another classic CCS bug to me. Several times I have
> found that #fuses bits work backwards in some of their releases, right
> now I have a project for the 'F73 that must use "NOPUT" to *enable* the
> power up timer. A sheepish tech at CCS explained that they are working on
> this after I wasted a couple of hours pulling out my hair..
>
> Try enabling your WDT, I'll bet the WDT will then turn off. Or else,
> upgrade to the version du jour.

I bet not. I know for a fact what he's setting will compile with the
correct fuse settings for the 'F87x series, I do it almost daily. That's
why I figured it was probably his programmer until he mentioned the MCHP
recommended sequence for switching the PSA and saw he was explicitly
setting PSA without doing that; that looks like the smoking gun.

> This sounds like another classic CCS bug to me. Several times I have
> found that #fuses bits work backwards in some of their releases, right
> now I have a project for the 'F73 that must use "NOPUT" to *enable* the
> power up timer. A sheepish tech at CCS explained that they are working on
> this after I wasted a couple of hours pulling out my hair..
>
> Try enabling your WDT, I'll bet the WDT will then turn off. Or else,
> upgrade to the version du jour.

I bet not. I know for a fact what he's setting will compile with the
correct fuse settings for the 'F87x series, I do it almost daily. That's
why I figured it was probably his programmer until he mentioned the MCHP
recommended sequence for switching the PSA and saw he was explicitly
setting PSA without doing that; that looks like the smoking gun.

> > Yes, but fiddling with the PSA bit can cause an unintended WDT reset
even
> > if it's disabled, apparently.
>
> I find that *very* hard to believe. Do you have any solid evidence to
> support this belief?

Well, yes, otherwise I wouldn't have said it. As the OP noted, you can
look at section 11.6.1 on page 11-8 of DS31101A, the PIC Midrange
reference manual.

"NOTE: To avoid an unintended device RESET, the following instruction
sequence (shown in Example 11-1) must be executed when changing the
prescaler assignment from TIMER0 to the WDT. This sequence must be
followed even if the WDT is disabled."

I'd say that explains why he gets a WDT reset when he manually twiddles
PSA even though he's got the WDT disabled. I had to look it up to be
sure, but there it is plain as day.

My problem is solved. I have my timer0 with a 1:1-prescaler and no unwilling
WDT-reset. But I haven't seen that I had also a problem of lack of intensity
in my circuit, which provoked also a reset. So please excuse me for all! My
training master, Samuel, is now very upset because you would think he was
stupid. But he is clean in the story (except if we considered he could have
helped me a little more for a so small problem... bad master! :-D )

Maxime

Maxime has just forgot to tell you that last month, he already got this
problem...
bad trainee! :-(