Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

mega88 clock divisor not reliable??

mega88 clock divisor not reliable??

2006-10-01 by larry barello

Anyone use the clock divisor on the m88?  Below is my code.  Every so often
the reset to normal speed fails.   Interrupts are disabled during the ISR()

 

In short my "system" has a 50hz clock and I divide the CPU clock by 128 when
I want low power and the timer wakes me up 2.56 seconds later.  Every so
often I get a 5 second delay.  If I put the reset inside the "bDeepSleep"
clause, it works a couple times and eventually gets stuck in low speed mode.

 

I have tried a variety of approaches: Sleep, no sleep, put into a while()
loop until the CLKPR is  equal to what I want (of course it is, but the
clock is still slow), etc.  The resulting assembly code is good: ldi, sts,
ldi, sts.  The one that fails is "ldi, sts, sts" (storing a zero comes out
of a register that the C compiler maintains).

 

while(1)

{

if (bDeepSleep)

      {

            SLEEP(TRUE);            // Radio sleep

            CloseSerialIO();        // Disable serial interrupts

            cli();

            CLKPR = 0x80;

            CLKPR = 0x07;           // Divide system clock by 128.

      }

      else

      {

            ProtocolTask();         // Communications with MCS via zibee

            WGRMTask();             // Handles overall state of the machine
&

      }

      sei();

      asm ("sleep");

}

 

// We rely upon slow clocks for low power in the mega88

// The timer interrupt restores the clock to full speed

// then lets the logic run.  The logic enables the radio

// and waits for a transaction (x ms) going back to sleep

// if nothing happens.

 

//void TIMER1_CAPT_vect (void) __attribute__ ((interrupt));

//void TIMER1_CAPT_vect (void);

ISR(TIMER1_CAPT_vect)

{

      CLKPR = 0x80;                 // Set clock back to full speed

      CLKPR = 0x00;

      if (bDeepSleep)               // 1/2.56 hz!

      {

            InitSerialIO(BAUD115200);     

            SLEEP(FALSE);           // Wake radio up

            bDeepSleep = FALSE;

      }

      else

            SystemTimer++;

}

 

 



[Non-text portions of this message have been removed]

Re: [AVR-Chat] mega88 clock divisor not reliable??

2006-10-01 by David VanHorn

On 9/30/06, larry barello <yahoo@barello.net> wrote:
>
> Anyone use the clock divisor on the m88?  Below is my code.  Every so
> often
> the reset to normal speed fails.   Interrupts are disabled during the
> ISR()


Are you doing at least 8 NOPS after the transition?
There's an errata about this, that you must follow a clock divison change by
at least 8 nops.


[Non-text portions of this message have been removed]

RE: [AVR-Chat] mega88 clock divisor not reliable??

2006-10-01 by larry barello

Thanks for the tip.  I'll try that next chance I get (I punted low power for
a while after pissing four hours on it yesterday).

So, how is life?  I have been more or less swamped with contract work the
last three years.  1-1/2 years working on a bar code scanner, then the last
year working on various military R&D projects relating to air delivery (e.g.
dropping stuff out of planes with parachutes).  The m88 is a wireless doodad
to "release" payloads based upon automated systems.  They want to fill the
plane and have it sit there for up to a week or so and still have the end
nodes work.

| -----Original Message-----
| From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
| Of David VanHorn
| Sent: Sunday, October 01, 2006 10:18 AM
| To: AVR-Chat@yahoogroups.com
| Subject: Re: [AVR-Chat] mega88 clock divisor not reliable??
| 
| On 9/30/06, larry barello <yahoo@barello.net> wrote:
| >
| > Anyone use the clock divisor on the m88?  Below is my code.  Every so
| > often
| > the reset to normal speed fails.   Interrupts are disabled during the
| > ISR()
| 
| 
| Are you doing at least 8 NOPS after the transition?
| There's an errata about this, that you must follow a clock divison change
| by
| at least 8 nops.
| 
| 
| [Non-text portions of this message have been removed]
| 
| 
| 
| 
| Yahoo! Groups Links
| 
| 
| 
| 
| 
| 
| 
|

Timer Counter

2006-10-02 by OWEN-A

I have a situation where a counter used in an interrupt may rollover before
a compare is reached, for example the timer is set to 0x26 within the
interrupt then decremented by one every time the interrupt is entered until
0 is reached, then reset to 0x26 again.

PORTD PIN0 is set high somewhere within the count of 26 down to 1  (or 0
within the interrupt) and has to be set low after say 0x1A counts,  if the
counter is read when PORTD PIN0 is set high and is on 0x0F the counter will
rollover before the turnoff point is reached, this may or may not happen
depending on when PORTD PIN0 is set.

I am not very proficient at assembly and any help would be appreciated I am
modifying another person's program and the processor is a PIC16F877.

 

Thanking You,

Owen

 

 



[Non-text portions of this message have been removed]

Re: [AVR-Chat] Timer Counter

2006-10-02 by Jim Wagner

Are you trying to modify a PIC program to operate on AVR?

Jim

On Mon, 2 Oct 2006 10:25:29 +1000
 "OWEN-A" <oldboot@bigpond.com> wrote:
> I have a situation where a counter used in an interrupt
> may rollover before
> a compare is reached, for example the timer is set to
> 0x26 within the
> interrupt then decremented by one every time the
> interrupt is entered until
> 0 is reached, then reset to 0x26 again.
> 
> PORTD PIN0 is set high somewhere within the count of 26
> down to 1  (or 0
> within the interrupt) and has to be set low after say
> 0x1A counts,  if the
> counter is read when PORTD PIN0 is set high and is on
> 0x0F the counter will
> rollover before the turnoff point is reached, this may or
> may not happen
> depending on when PORTD PIN0 is set.
> 
> I am not very proficient at assembly and any help would
> be appreciated I am
> modifying another person's program and the processor is a
> PIC16F877.
> 
>  
> 
> Thanking You,
> 
> Owen
> 
>  
> 
>  
> 
> 
> 
> [Non-text portions of this message have been removed]
> 

---------------------------------------------------------------
The Think Different Store
http://www.thinkdifferentstore.com/
For All Your Mac Gear
---------------------------------------------------------------

Re: Timer Counter

2006-10-03 by Celso Monteiro

Dear Owen,

It seems to me you've got a noise problem that is corrupting your 
latch. It would be interesting for you to investigate what's going 
on. One suggestion I can tell you is periodically rewrite the 
contents of you latch. Shit happens all the time for everyone. What 
makes the difference is what you do after that.

Good luck,

Celso



--- In AVR-Chat@yahoogroups.com, "OWEN-A" <oldboot@...> wrote:
>
> I am trying to modifying a PIC program to get a shift register to 
work
> properly, toggle the clear pin on the shift register to force all 
outputs to
> "0" to prevent it from holding the data for too long and burning 
out an
> expensive solenoid.
> 
> The shift register is a 74HC595 and will occasionally lock an 
output on for
> a long enough period to destroy a solenoid.
> 
> These solenoids are $350-00 each and they burn out around 40 to 50 
a year on
> the system.
> 
> Have tried a PIC group but have not received any replies.
> 
> I normally use AVR's with a C compiler the more that I see of the 
PIC the
Show quoted textHide quoted text
> more I dislike them!
> 
> Thanking You,
> 
> Owen.
> 
>  
> 
>  
> 
> Are you trying to modify a PIC program to operate on AVR?
> 
>  
> 
> Jim
> 
>  
> 
> On Mon, 2 Oct 2006 10:25:29 +1000
> 
>  "OWEN-A" <oldboot@...> wrote:
> 
> > I have a situation where a counter used in an interrupt
> 
> > may rollover before
> 
> > a compare is reached, for example the timer is set to
> 
> > 0x26 within the
> 
> > interrupt then decremented by one every time the
> 
> > interrupt is entered until
> 
> > 0 is reached, then reset to 0x26 again.
> 
> > 
> 
> > PORTD PIN0 is set high somewhere within the count of 26
> 
> > down to 1  (or 0
> 
> > within the interrupt) and has to be set low after say
> 
> > 0x1A counts,  if the
> 
> > counter is read when PORTD PIN0 is set high and is on
> 
> > 0x0F the counter will
> 
> > rollover before the turnoff point is reached, this may or
> 
> > may not happen
> 
> > depending on when PORTD PIN0 is set.
> 
> > 
> 
> > I am not very proficient at assembly and any help would
> 
> > be appreciated I am
> 
> > modifying another person's program and the processor is a
> 
> > PIC16F877.
> 
> > 
> 
> >  
> 
> > 
> 
> > Thanking You,
> 
> > 
> 
> > Owen
> 
> > 
> 
> >  
> 
> > 
> 
> >  
> 
> > 
> 
> > 
> 
> > 
> 
> > [Non-text portions of this message have been removed]
> 
> > 
> 
>  
> 
> ---------------------------------------------------------------
> 
> The Think Different Store
> 
> http://www.thinkdifferentstore.com/
> 
> For All Your Mac Gear
> 
> ---------------------------------------------------------------
> 
>  
> 
>  
> 
>  
> 
> Yahoo! Groups Links
> 
>  
> 
> 
>  
> 
> 
>  
> 
> 
>     (Yahoo! ID required)
> 
>  
> 
> 
>     mailto:AVR-Chat-fullfeatured@yahoogroups.com
> 
>  
> 
> 
>  
> 
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 
> 
> [Non-text portions of this message have been removed]
>

RE: [AVR-Chat] Timer Counter

2006-10-03 by OWEN-A

I am trying to modifying a PIC program to get a shift register to work
properly, toggle the clear pin on the shift register to force all outputs to
"0" to prevent it from holding the data for too long and burning out an
expensive solenoid.

The shift register is a 74HC595 and will occasionally lock an output on for
a long enough period to destroy a solenoid.

These solenoids are $350-00 each and they burn out around 40 to 50 a year on
the system.

Have tried a PIC group but have not received any replies.

I normally use AVR's with a C compiler the more that I see of the PIC the
more I dislike them!

Thanking You,

Owen.

 

 

Are you trying to modify a PIC program to operate on AVR?

 

Jim

 

On Mon, 2 Oct 2006 10:25:29 +1000

 "OWEN-A" <oldboot@bigpond.com> wrote:

> I have a situation where a counter used in an interrupt

> may rollover before

> a compare is reached, for example the timer is set to

> 0x26 within the

> interrupt then decremented by one every time the

> interrupt is entered until

> 0 is reached, then reset to 0x26 again.

> 

> PORTD PIN0 is set high somewhere within the count of 26

> down to 1  (or 0

> within the interrupt) and has to be set low after say

> 0x1A counts,  if the

> counter is read when PORTD PIN0 is set high and is on

> 0x0F the counter will

> rollover before the turnoff point is reached, this may or

> may not happen

> depending on when PORTD PIN0 is set.

> 

> I am not very proficient at assembly and any help would

> be appreciated I am

> modifying another person's program and the processor is a

> PIC16F877.

> 

>  

> 

> Thanking You,

> 

> Owen

> 

>  

> 

>  

> 

> 

> 

> [Non-text portions of this message have been removed]

> 

 

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

The Think Different Store

http://www.thinkdifferentstore.com/

For All Your Mac Gear

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

 

 

 

Yahoo! Groups Links

 


 


 


    (Yahoo! ID required)

 


    mailto:AVR-Chat-fullfeatured@yahoogroups.com

 


 


 

 

 

 

 

 



[Non-text portions of this message have been removed]

Re: [AVR-Chat] Timer Counter

2006-10-03 by Leon Heller

----- Original Message ----- 
Show quoted textHide quoted text
From: "OWEN-A" <oldboot@bigpond.com>
To: <AVR-Chat@yahoogroups.com>
Sent: Tuesday, October 03, 2006 12:41 PM
Subject: RE: [AVR-Chat] Timer Counter


>I am trying to modifying a PIC program to get a shift register to work
> properly, toggle the clear pin on the shift register to force all outputs 
> to
> "0" to prevent it from holding the data for too long and burning out an
> expensive solenoid.
>
> The shift register is a 74HC595 and will occasionally lock an output on 
> for
> a long enough period to destroy a solenoid.
>
> These solenoids are $350-00 each and they burn out around 40 to 50 a year 
> on
> the system.
>
> Have tried a PIC group but have not received any replies.
>
> I normally use AVR's with a C compiler the more that I see of the PIC the
> more I dislike them!

Sounds like a problem with a transient on the supply. Something like an AVX 
TransGuard will cure the problem.

Leon

RE: [AVR-Chat] Timer Counter

2006-10-03 by OWEN-A

>I am trying to modifying a PIC program to get a shift register to work

> properly, toggle the clear pin on the shift register to force all outputs 

> to

> "0" to prevent it from holding the data for too long and burning out an

> expensive solenoid.

> 

> The shift register is a 74HC595 and will occasionally lock an output on 

> for

> a long enough period to destroy a solenoid.

> 

> These solenoids are $350-00 each and they burn out around 40 to 50 a year 

> on

> the system.

> 

> Have tried a PIC group but have not received any replies.

> 

> I normally use AVR's with a C compiler the more that I see of the PIC the

> more I dislike them!

 

Sounds like a problem with a transient on the supply. Something like an AVX 

TransGuard will cure the problem.

 

Leon 

 

These units are in the field on 12 volt battery supply with solar panel
charging system (no mains supply) the 12 volt solenoid's are driven by
VNP5N07 Fully protected power mosfets     (ST Microelectronics devices)
switching one end of the solenoid to V- the other end of the solenoid is
connected the battery V+ .

The 1N4004 protection diodes are across the mosfets "not the solenoids" (no
diodes across the solenoids).

I had not noticed this before but perhaps the internal resistance of the
batteries may be high enough that the ringing of the solenoid coil could be
causing a spike on the supply??? 

Sorry for the HTML!

Thanking You,

Owen.



[Non-text portions of this message have been removed]

Re: [AVR-Chat] Timer Counter

2006-10-03 by Dave Hylands

Hi Owen,

On 10/3/06, OWEN-A <oldboot@bigpond.com> wrote:
> I am trying to modifying a PIC program to get a shift register to work
> properly, toggle the clear pin on the shift register to force all outputs to
> "0" to prevent it from holding the data for too long and burning out an
> expensive solenoid.
>
> The shift register is a 74HC595 and will occasionally lock an output on for
> a long enough period to destroy a solenoid.

Clearing is a two stage operation. If you take a look at the
datasheet, you'll see that there are really two 8 bit registers, one
is a shift register, and one is the output register.. The output
register is what you see on the pins. The clear connects to the shift
portion of the register.

So to clear the register, you need to drive the clear line low for a
minimum of 20 nanosecs (this clears the shift register portion), and
then strobe the RCK line from low to high to load these zeros into the
output register. The RCK line needs to stay high for a minimum of 20
nanosecs as well.

-- 
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

Re: [AVR-Chat] Timer Counter

2006-10-05 by Roy E. Burrage

You might want to go back and add diodes across those solenoids, Owen.  
Transients on the power line can cause you all sorts of problems that a 
3 cent diode will solve.

We once had a customer who had us modifying some control modules that 
they sent all over the world.  They had a problem with something letting 
all the smoke out of the power drivers and warranty repairs were killing 
us.  I went over to their place and did some system evaluation and found 
the problem to be coming from transients generated by a clutch/brake 
assembly.  With a high voltage scope probe and Tektronix 465 scope, all 
I could see of the transient was about 1,000 volts...and it was way off 
the display so I never could see what the peak values were.  These 
transients were also several microseconds in duration.  A 1N4004 across 
the coil of the clutch/brake cured the problem...and we made money from 
then on.

The clutch/brake was drawing less than half an amp at 24 volts DC so it 
doesn't take a lot of current or voltage to generate humongous 
transients.  All it takes is a lot of ampere turns.  Diodes should be 
physically mounted as close to the solenoids as possible.


REB



OWEN-A wrote:

> 
>
>  
>
>>I am trying to modifying a PIC program to get a shift register to work
>>    
>>
>
>  
>
>>properly, toggle the clear pin on the shift register to force all outputs 
>>    
>>
>
>  
>
>>to
>>    
>>
>
>  
>
>>"0" to prevent it from holding the data for too long and burning out an
>>    
>>
>
>  
>
>>expensive solenoid.
>>    
>>
>
>  
>
>
>  
>
>>The shift register is a 74HC595 and will occasionally lock an output on 
>>    
>>
>
>  
>
>>for
>>    
>>
>
>  
>
>>a long enough period to destroy a solenoid.
>>    
>>
>
>  
>
>
>  
>
>>These solenoids are $350-00 each and they burn out around 40 to 50 a year 
>>    
>>
>
>  
>
>>on
>>    
>>
>
>  
>
>>the system.
>>    
>>
>
>  
>
>
>  
>
>>Have tried a PIC group but have not received any replies.
>>    
>>
>
>  
>
>
>  
>
>>I normally use AVR's with a C compiler the more that I see of the PIC the
>>    
>>
>
>  
>
>>more I dislike them!
>>    
>>
>
> 
>
>Sounds like a problem with a transient on the supply. Something like an AVX 
>
>TransGuard will cure the problem.
>
> 
>
>Leon 
>
> 
>
>These units are in the field on 12 volt battery supply with solar panel
>charging system (no mains supply) the 12 volt solenoid's are driven by
>VNP5N07 Fully protected power mosfets     (ST Microelectronics devices)
>switching one end of the solenoid to V- the other end of the solenoid is
>connected the battery V+ .
>
>The 1N4004 protection diodes are across the mosfets "not the solenoids" (no
>diodes across the solenoids).
>
>I had not noticed this before but perhaps the internal resistance of the
>batteries may be high enough that the ringing of the solenoid coil could be
>causing a spike on the supply??? 
>
>Sorry for the HTML!
>
>Thanking You,
>
>Owen.
>
>
>
>[Non-text portions of this message have been removed]
>
>
>
> 
>Yahoo! Groups Links
>
>
>
>
>
>
> 
>
>
>
>
>
>  
>


[Non-text portions of this message have been removed]

RE: [AVR-Chat] Timer Counter

2006-10-05 by OWEN-A

Thank you all for the replies.

I normally put a 1N4004 diode across the inductor and a BZY18 Zener diode
across the 12 volt supply with a 2Amp fuse before the Zener diode on my own
designs.

I have not designed these boards myself and have only seen a couple of the
boards not the installation, there is a diode across the driver FET on the
board but I now suspect that there may not be any across the solenoid coils.

I think that perhaps I had better go and have a look at the installation
take my Tektronix THS720 scope with me and do a few measurements.

Just done a test with a 12Volt SLA battery and a 12Volt relay coil to prove
the point, 20Volt spike across the battery with a 1N4004 diode across the
coil, 600Volt spike across the battery without the diode, looks like the
original designer may have been expecting the battery to absorb the spike!!
Or ???

 

Thanking You,

Owen.

  

 

All outgoing emails scanned by Trend Micro
Show quoted textHide quoted text
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of Roy E. Burrage
Sent: Thursday, October 05, 2006 2:12 PM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Timer Counter

 

You might want to go back and add diodes across those solenoids, Owen.  

Transients on the power line can cause you all sorts of problems that a 

3 cent diode will solve.

 

We once had a customer who had us modifying some control modules that 

they sent all over the world.  They had a problem with something letting 

all the smoke out of the power drivers and warranty repairs were killing 

us.  I went over to their place and did some system evaluation and found 

the problem to be coming from transients generated by a clutch/brake 

assembly.  With a high voltage scope probe and Tektronix 465 scope, all 

I could see of the transient was about 1,000 volts...and it was way off 

the display so I never could see what the peak values were.  These 

transients were also several microseconds in duration.  A 1N4004 across 

the coil of the clutch/brake cured the problem...and we made money from 

then on.

 

The clutch/brake was drawing less than half an amp at 24 volts DC so it 

doesn't take a lot of current or voltage to generate humongous 

transients.  All it takes is a lot of ampere turns.  Diodes should be 

physically mounted as close to the solenoids as possible.

 

 

REB

 

 

 

OWEN-A wrote:

 

> 

> 

>  

> 

>>I am trying to modifying a PIC program to get a shift register to work

>>    

>> 

> 

>  

> 

>>properly, toggle the clear pin on the shift register to force all outputs 

>>    

>> 

> 

>  

> 

>>to

>>    

>> 

> 

>  

> 

>>"0" to prevent it from holding the data for too long and burning out an

>>    

>> 

> 

>  

> 

>>expensive solenoid.

>>    

>> 

> 

>  

> 

> 

>  

> 

>>The shift register is a 74HC595 and will occasionally lock an output on 

>>    

>> 

> 

>  

> 

>>for

>>    

>> 

> 

>  

> 

>>a long enough period to destroy a solenoid.

>>    

>> 

> 

>  

> 

> 

>  

> 

>>These solenoids are $350-00 each and they burn out around 40 to 50 a year 

>>    

>> 

> 

>  

> 

>>on

>>    

>> 

> 

>  

> 

>>the system.

>>    

>> 

> 

>  

> 

> 

>  

> 

>>Have tried a PIC group but have not received any replies.

>>    

>> 

> 

>  

> 

> 

>  

> 

>>I normally use AVR's with a C compiler the more that I see of the PIC the

>>    

>> 

> 

>  

> 

>>more I dislike them!

>>    

>> 

> 

> 

> 

>Sounds like a problem with a transient on the supply. Something like an AVX


> 

>TransGuard will cure the problem.

> 

> 

> 

>Leon 

> 

> 

> 

>These units are in the field on 12 volt battery supply with solar panel

>charging system (no mains supply) the 12 volt solenoid's are driven by

>VNP5N07 Fully protected power mosfets     (ST Microelectronics devices)

>switching one end of the solenoid to V- the other end of the solenoid is

>connected the battery V+ .

> 

>The 1N4004 protection diodes are across the mosfets "not the solenoids" (no

>diodes across the solenoids).

> 

>I had not noticed this before but perhaps the internal resistance of the

>batteries may be high enough that the ringing of the solenoid coil could be

>causing a spike on the supply??? 

> 

>Sorry for the HTML!

> 

>Thanking You,

> 

>Owen.

> 

> 

> 

>[Non-text portions of this message have been removed]

> 

> 

> 

> 

>Yahoo! Groups Links

> 

> 

> 

> 

> 

> 

> 

> 

> 

> 

> 

> 

>  

> 

 

 

[Non-text portions of this message have been removed]

 

 

 

 

Yahoo! Groups Links

 


 


 


    (Yahoo! ID required)

 


    mailto:AVR-Chat-fullfeatured@yahoogroups.com

 


 


 

 

 

 



[Non-text portions of this message have been removed]

Induction Voltage Spikes (was: Re: Timer Counter)

2006-10-05 by Stefan Wimmer

--- In AVR-Chat@yahoogroups.com, "OWEN-A" <oldboot@...> wrote:
>...
> 
> Just done a test with a 12Volt SLA battery and a 12Volt relay coil 
to prove
> the point, 20Volt spike across the battery with a 1N4004 diode 
across the
> coil, 600Volt spike across the battery without the diode, looks 
like the
> original designer may have been expecting the battery to absorb the 
spike!!
> Or ???

Uhhh!?!
You mean there really are people designig circuits like this??

dU = -L * dI/dt is not electronics 101, it's even basic physics 101.
Everybody touching electronic parts in order to do professional work 
(IOW: for making money) should at least have some really basic 
knowledge of something like this.

Ok, ok - thanks for welcoming me back in reality.... :-))

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.