Yahoo Groups archive

AVR-Chat

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

Thread

RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-11 by Steven Holder

What are your start up settings for the clock ? I.e the clock fuses, try
setting the start up delay to be a bit longer (16k +64ms) this I think will
help it out.
 
Regards
 

  _____  
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of Cat C
Sent: 11 March 2010 19:15
To: avr-chat@yahoogroups.com
Subject: [AVR-Chat] Code stuck waiting for SPI transmission but only after
power-up. (ATMega644P)


  


Me again... :-)

My code sends stuff over SPI, like this:

SPDR = something;
while(!(SPSR & (1<<SPIF))) //Wait for transmission complete
{ ; }

I know I should have a counter and get out with an error, but... that's
beside the point...

This used to work fine, but at some point it started to get stuck on the
"while" first time I power up the board.
It works fine after a reset.

Any ideas please?

Thanks,

Cat


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






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

Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-11 by Cat C

Me again... :-)

My code sends stuff over SPI, like this:


    SPDR = something;
    while(!(SPSR & (1<<SPIF)))    //Wait for transmission complete
    {    ;    }

I know I should have a counter and get out with an error, but... that's beside the point...

This used to work fine, but at some point it started to get stuck on the "while" first time I power up the board.
It works fine after a reset.

Any ideas please?

Thanks,

Cat
 		 	   		  

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

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-11 by Mike

Cat,

All you emails seems to me to somehow keep pointing to Power Supply.
BrownOut condition during start-up?

If I press the reset button all is fine, so maybe strange things happen because power might go up too slow.

Can you verify this, purhaps a different supply? Hopefully.

Wish I could be of more help.

Mike
Show quoted textHide quoted text
  ----- Original Message ----- 
  From: Cat C 
  To: avr-chat@yahoogroups.com 
  Sent: Thursday, March 11, 2010 11:14 AM
  Subject: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)


    

  Me again... :-)

  My code sends stuff over SPI, like this:

  SPDR = something;
  while(!(SPSR & (1<<SPIF))) //Wait for transmission complete
  { ; }

  I know I should have a counter and get out with an error, but... that's beside the point...

  This used to work fine, but at some point it started to get stuck on the "while" first time I power up the board.
  It works fine after a reset.

  Any ideas please?

  Thanks,

  Cat


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



  

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

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-11 by John Samperi

At 06:14 AM 12/03/2010, you wrote:
>This used to work fine, but at some point it started to get stuck on 
>the "while" first time I power up the board.
>It works fine after a reset.

What are you doing with the /SS pin? Is it an output?

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-11 by Cat C

> What are you doing with the /SS pin? Is it an output?

I use the SS pin for one of the Chips Selects, so it is an output.

Thanks John.

>>>

>What are your start up settings for the clock ? I.e the clock fuses, try
>setting the start up delay to be a bit longer (16k +64ms) this I think will
>help it out.I tried all (only 3 for external crystal) clock settings; also all BOD levels available.

Thanks Steven,

One thing I noticed is that it doesn't matter how long after power up I try to send stuff on the SPI, it never works until I reset.


 		 	   		  

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

RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-11 by Cat C

I do think you're right Mike, as it started after I put the linear regulator in, just to protect the microcontroller from the big bad PC PSU, but I want to know WHAT IS IT!

I'm now wondering:  Is it possible that the Big Bad PC PSU broke my microcontroller in such a way that it generally works, but something... doesn't?

Thanks,

Cat

> To: AVR-Chat@yahoogroups.com
> From: benoitmc2@msn.com
> Date: Thu, 11 Mar 2010 11:54:22 -0800
> Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)
> 
> Cat,
> 
> All you emails seems to me to somehow keep pointing to Power Supply.
> BrownOut condition during start-up?
> 
> If I press the reset button all is fine, so maybe strange things happen because power might go up too slow.
> 
> Can you verify this, purhaps a different supply? Hopefully.
> 
> Wish I could be of more help.
> 
> Mike
> 

 		 	   		  

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

Re: Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-12 by Terrance

Just had a similar problem this week (changed the power input to go through a schottkey, SPI comm started acting up).  Lowering the brownout from 4.3 to 2.7 fixed it.  Setting the fuse to let the clock settle longer is a good idea as well.

-Terrance

--- In AVR-Chat@yahoogroups.com, Cat C <catalin_cluj@...> wrote:
Show quoted textHide quoted text
>
> 
> Me again... :-)
> 
> My code sends stuff over SPI, like this:
> 
> 
>     SPDR = something;
>     while(!(SPSR & (1<<SPIF)))    //Wait for transmission complete
>     {    ;    }
> 
> I know I should have a counter and get out with an error, but... that's beside the point...
> 
> This used to work fine, but at some point it started to get stuck on the "while" first time I power up the board.
> It works fine after a reset.
> 
> Any ideas please?
> 
> Thanks,
> 
> Cat
>  		 	   		  
> 
> [Non-text portions of this message have been removed]
>

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-12 by Mike

1. For some reason, at power-up (4.5V from linear on-board regulator from PC 5V PSU) the microcontroller starts up temporarily but then stops (or goes to microcontroller heaven). 

I assume you have 5 volt device (Micro)- but stated 4.5 v supplied to it.... This seems to low for anything to be dependable..for a 5 volt device. Remember you stated it worked fine without the linear regulator, that may be do to the fact that the micro was getting the full 5 volts and was happy.

I do think you're right Mike, as it started after I put the linear regulator in, just to protect the microcontroller from the big bad PC PSU, but I want to know WHAT IS IT!

I was wondering what inspired you to protect the microcontroller from the big bad supply PC PSU with the linear regulator in the first place, I would assume the PSU is already regulated. If dirty supply you could add filter. If worried about over voltage,a zener perhaps. It just appears from what you wrote that the problem did not exist until you added the Linear Regulator...Then the problem appeared...This at least can be reversed back to original (without the Linear Regulator) to see if the problem disappears. That would just tell you that a different approach may be necessary.

Also, looking at the reset line with your scope at power up may reveal something. Just a thought. Such as soft on the pull-up (ie. RESET GLITCH) should be nice and clean. but my gut tells me "Power"

Hoping your making progress.
Regards, Mike
Show quoted textHide quoted text
  ----- Original Message ----- 
  From: Cat C 
  To: avr-chat@yahoogroups.com 
  Sent: Thursday, March 11, 2010 1:13 PM
  Subject: RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)


    

  I do think you're right Mike, as it started after I put the linear regulator in, just to protect the microcontroller from the big bad PC PSU, but I want to know WHAT IS IT!

  I'm now wondering: Is it possible that the Big Bad PC PSU broke my microcontroller in such a way that it generally works, but something... doesn't?

  Thanks,

  Cat

  > To: AVR-Chat@yahoogroups.com
  > From: benoitmc2@msn.com
  > Date: Thu, 11 Mar 2010 11:54:22 -0800
  > Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)
  > 
  > Cat,
  > 
  > All you emails seems to me to somehow keep pointing to Power Supply.
  > BrownOut condition during start-up?
  > 
  > If I press the reset button all is fine, so maybe strange things happen because power might go up too slow.
  > 
  > Can you verify this, purhaps a different supply? Hopefully.
  > 
  > Wish I could be of more help.
  > 
  > Mike
  > 



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



  

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

RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-12 by Cat C

I went and used the Watchdog timer to give me a reset after a second, since it stays in the SPI loop so doesn't get to kick the dog :-D

The rest of it is curiosity, I'm more interested in how the SPI ONLY gets stuck under certain power conditions then try to fix it, so I may never will.

Thanks,

Cat


> To: AVR-Chat@yahoogroups.com
> From: benoitmc2@msn.com
> Date: Fri, 12 Mar 2010 12:06:57 -0800
> Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)
> 
>  Cat,
> 
> Also on that reset, as you know, it should go rail to rail. Solidly (0 to 5V)
> 
> Just keep applying your good logic, you'll get it...
> 
> Regards, Mike
> 
> 
> 
> [Non-text portions of this message have been removed]
> 
> 
 		 	   		  

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

RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-12 by Cat C

> 
> I assume you have 5 volt device (Micro)- but stated 4.5 v supplied to it.... This seems to low for anything to be >dependable..for a 5 volt device. 

It's a 2.7 - 5.5V


> I was wondering what inspired you to protect the microcontroller from the big bad supply PC PSU with the linear regulator in the first place, I would assume the PSU is already regulated. If dirty supply you could add filter. If worried about over voltage,a zener perhaps. It just appears from what you wrote that the problem did not exist until you added the Linear Regulator...Then the problem appeared...This at least can be reversed back to original (without the Linear Regulator) to see if the problem disappears. That would just tell you that a different approach may be necessary.

Yes I think it's because of the regulator.  There is a filter too (LC), but... considering how many sources PC PSUs come from, I felt it's nice to go the extra step.
I think a zener would need to be a mighty one to prevent spikes from a PSU that can provide maybe 15-30A.

> Also, looking at the reset line with your scope at power up may reveal something. Just a thought. Such as soft on the pull-up (ie. RESET GLITCH) should be nice and clean. but my gut tells me "Power"

I looked, couldn't see anything relevant.

Everything else (just not the SPI) seems to work.

Thanks Mike

> 
> Hoping your making progress.
> Regards, Mike
> 
> 
>   ----- Original Message ----- 
>   From: Cat C 
>   To: avr-chat@yahoogroups.com 
>   Sent: Thursday, March 11, 2010 1:13 PM
>   Subject: RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)
> 
> 
>     
> 
>   I do think you're right Mike, as it started after I put the linear regulator in, just to protect the microcontroller from the big bad PC PSU, but I want to know WHAT IS IT!
> 
>   I'm now wondering: Is it possible that the Big Bad PC PSU broke my microcontroller in such a way that it generally works, but something... doesn't?
> 
>   Thanks,
> 
>   Cat
> 
>   > To: AVR-Chat@yahoogroups.com
>   > From: benoitmc2@msn.com
>   > Date: Thu, 11 Mar 2010 11:54:22 -0800
>   > Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)
>   > 
>   > Cat,
>   > 
>   > All you emails seems to me to somehow keep pointing to Power Supply.
>   > BrownOut condition during start-up?
>   > 
>   > If I press the reset button all is fine, so maybe strange things happen because power might go up too slow.
>   > 
>   > Can you verify this, purhaps a different supply? Hopefully.
>   > 
>   > Wish I could be of more help.
>   > 
>   > Mike
>   > 
> 
> 
> 
>   [Non-text portions of this message have been removed]
> 
> 
> 
>   
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
> ------------------------------------
> 
> Yahoo! Groups Links
> 
> 
> 
 		 	   		  

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

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-12 by Mike

Cat,

I think a zener would need to be a mighty one to prevent spikes from a PSU that can provide maybe 15-30A. 

Current limit resistor first (300ma if I remember), then zener.

The rest of it is curiosity, I'm more interested in how the SPI ONLY gets stuck under certain power conditions then try to fix it, so I may never will.

Understandable...

Regards, Mike



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

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-13 by erikc

My two cents:

I find it helpful to provide the CPU with its very own voltage 
regulator (something like a 78L05 is sufficient) to be very helpful.
Make sure to properly bypass the regulator on both input and output 
with at least 2 uF.

Any routine I write that depends on a response from a peripheral is
also coded with a counter to act as a timer.  The number of counts
is chosen so that the expiration time is well in excess of the 
response time of the peripheral.  If the counter expires, it is
assumed that something caused the peripheral not to respond in a
timely manner.  This is especially useful with peripherals using
handshaking.

Here is how I do SPI.

bool SPISend( char c)
{
    short counter;

    SPDR = c;
    counter = 10000;           // or some other appropriate number
    while(!(SPSR & (1<<SPIF))  // Wait for transmission complete
        && (counter > 0)       // and counter not zeroed
    { counter--; }
    return( counter > 0)	      // counter > 0 so xmit successful
} /* SPISend */

Mike wrote:
Show quoted textHide quoted text
> Cat,
> 
> All you emails seems to me to somehow keep pointing to Power Supply.
> BrownOut condition during start-up?
> 
> If I press the reset button all is fine, so maybe strange things happen because power might go up too slow.
> 
> Can you verify this, purhaps a different supply? Hopefully.
> 
> Wish I could be of more help.
> 
> Mike
> 
> 
> 
> 
>   ----- Original Message ----- 
>   From: Cat C 
>   To: avr-chat@yahoogroups.com 
>   Sent: Thursday, March 11, 2010 11:14 AM
>   Subject: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)
> 
> 
>     
> 
>   Me again... :-)
> 
>   My code sends stuff over SPI, like this:
> 
>   SPDR = something;
>   while(!(SPSR & (1<<SPIF))) //Wait for transmission complete
>   { ; }
> 
>   I know I should have a counter and get out with an error, but... that's beside the point...
> 
>   This used to work fine, but at some point it started to get stuck on the "while" first time I power up the board.
>   It works fine after a reset.
> 
>   Any ideas please?
> 
>   Thanks,
> 
>   Cat

RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-14 by Cat C

The voltage is fine once it's up, everything works after a reset.

I tried the counter approach and it did tell me it timed out.
However, I had to revert to no-timer so it gets stuck there so the watchdog doesn't get kicked, so I get a reset and then it works :-)

Thanks,

Cat

> To: AVR-Chat@yahoogroups.com
> From: firewevr@airmail.net
> Date: Sat, 13 Mar 2010 19:11:15 +0000
> Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)
> 
> My two cents:
> 
> I find it helpful to provide the CPU with its very own voltage 
> regulator (something like a 78L05 is sufficient) to be very helpful.
... 
> Any routine I write that depends on a response from a peripheral is
> also coded with a counter to act as a timer.  The number of counts
...
 		 	   		  

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

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-14 by erikc

My understanding is that you have to feed the watchdog from time to 
time in various parts of the programme, and that would include 
software timer or stall loops as well.

You could feed the watchdog from inside the counter loop.  Then, you'd 
still get the timeout.

Cat C wrote:
Show quoted textHide quoted text
> The voltage is fine once it's up, everything works after a reset.
> 
> I tried the counter approach and it did tell me it timed out.
> However, I had to revert to no-timer so it gets stuck there so the watchdog doesn't get kicked, so I get a reset and then it works :-)
> 
> Thanks,

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-14 by Bob Paddock

On Sun, Mar 14, 2010 at 9:47 AM, erikc <firewevr@airmail.net> wrote:

>
>
>
> My understanding is that you have to feed the watchdog from time to
> time in various parts of the programme, and that would include
> software timer or stall loops as well.
>

http://www.ganssle.com/watchdogs.htm

>You could feed the watchdog from inside the counter loop. Then, you'd
>still get the timeout.

Bad idea to feed watchdog from inside of loops.  Better to set a time out
that is long enough for the loop to complete,
then refresh the watchdog before entering the loop and right after exiting
the loop.  Look at the link above for better ideas.

-- 
http://www.wearablesmartsensors.com/
http://www.softwaresafety.net/
http://www.designer-iii.com/
http://www.unusualresearch.com/


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

RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-14 by Cat C

I kick the dog in the main loop, not the SPI loop, so that works fine when there are no problems.
I WANT to get a reset if SPI doesn't work, so I DON'T want it to time out and exit.

> To: AVR-Chat@yahoogroups.com
> From: bob.paddock@gmail.com
> Date: Sun, 14 Mar 2010 09:59:04 -0400
> Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after 	power-up. (ATMega644P)
> 
> On Sun, Mar 14, 2010 at 9:47 AM, erikc <firewevr@airmail.net> wrote:
> 
> >
> >
> >
> > My understanding is that you have to feed the watchdog from time to
> > time in various parts of the programme, and that would include
> > software timer or stall loops as well.
> >
> 
> http://www.ganssle.com/watchdogs.htm
> 
> >You could feed the watchdog from inside the counter loop. Then, you'd
> >still get the timeout.
> 
> Bad idea to feed watchdog from inside of loops.  Better to set a time out
> that is long enough for the loop to complete,
> then refresh the watchdog before entering the loop and right after exiting
> the loop.  Look at the link above for better ideas.
>
> [Non-text portions of this message have been removed]
> 

 		 	   		  

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

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-14 by Dennis Clark

The watchdog is a pretty extreme way to get out of a communications 
timeout loop.  Have you considered using a regular interrupt instead and 
clean up the SPI call in that?  In my mind the doggy is best used to 
recover from going into the weeds, not from a simple communications timeout.

DLC

On 3/14/10 10:11 AM, Cat C wrote:
> I kick the dog in the main loop, not the SPI loop, so that works fine when there are no problems.
> I WANT to get a reset if SPI doesn't work, so I DON'T want it to time out and exit.
>
>    
>> To: AVR-Chat@yahoogroups.com
>> From: bob.paddock@gmail.com
>> Date: Sun, 14 Mar 2010 09:59:04 -0400
>> Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after 	power-up. (ATMega644P)
>>
>> On Sun, Mar 14, 2010 at 9:47 AM, erikc<firewevr@airmail.net>  wrote:
>>
>>      
>>>
>>>
>>> My understanding is that you have to feed the watchdog from time to
>>> time in various parts of the programme, and that would include
>>> software timer or stall loops as well.
>>>
>>>        
>> http://www.ganssle.com/watchdogs.htm
>>
>>      
>>> You could feed the watchdog from inside the counter loop. Then, you'd
>>> still get the timeout.
>>>        
>> Bad idea to feed watchdog from inside of loops.  Better to set a time out
>> that is long enough for the loop to complete,
>> then refresh the watchdog before entering the loop and right after exiting
>> the loop.  Look at the link above for better ideas.
>>
>> [Non-text portions of this message have been removed]
>>
>>      
>   		 	   		
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>    

-- 
Dennis Clark
TTT Enterprises

RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-15 by Cat C

The watchdog does it's job, it just happens to be the convenient way to have a reset a little while after a power up, if the SPI doesn't work.
I don't see any other way of "cleaning" the SPI.
It's not a simple communication timeout, it's a complicated one, and if I have 1000 SPI calls, they will all fail until I do a reset.
If you're gonna propose a reset chip, or other circuitry to get a reset other ways, why?  This works fine.

> To: AVR-Chat@yahoogroups.com
> CC: catalin_cluj@hotmail.com
> From: dlc@frii.com
> Date: Sun, 14 Mar 2010 12:21:27 -0600
> Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after 	power-up. (ATMega644P)
> 
> The watchdog is a pretty extreme way to get out of a communications 
> timeout loop.  Have you considered using a regular interrupt instead and 
> clean up the SPI call in that?  In my mind the doggy is best used to 
> recover from going into the weeds, not from a simple communications timeout.
> 
> DLC
> 
> On 3/14/10 10:11 AM, Cat C wrote:
> > I kick the dog in the main loop, not the SPI loop, so that works fine when there are no problems.
> > I WANT to get a reset if SPI doesn't work, so I DON'T want it to time out and exit.
> >
> >    
> >> To: AVR-Chat@yahoogroups.com
> >> From: bob.paddock@gmail.com
> >> Date: Sun, 14 Mar 2010 09:59:04 -0400
> >> Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after 	power-up. (ATMega644P)
> >>
> >> On Sun, Mar 14, 2010 at 9:47 AM, erikc<firewevr@airmail.net>  wrote:
> >>
> >>      
> >>>
> >>>
> >>> My understanding is that you have to feed the watchdog from time to
> >>> time in various parts of the programme, and that would include
> >>> software timer or stall loops as well.
> >>>
> >>>        
> >> http://www.ganssle.com/watchdogs.htm
> >>
> >>      
> >>> You could feed the watchdog from inside the counter loop. Then, you'd
> >>> still get the timeout.
> >>>        
> >> Bad idea to feed watchdog from inside of loops.  Better to set a time out
> >> that is long enough for the loop to complete,
> >> then refresh the watchdog before entering the loop and right after exiting
> >> the loop.  Look at the link above for better ideas.
> >>
> >> [Non-text portions of this message have been removed]
> >>
> >>      
> >   		 	   		
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >    
> 
> -- 
> Dennis Clark
> TTT Enterprises
> 
> 
> 
> ------------------------------------
> 
> Yahoo! Groups Links
> 
> 
> 
 		 	   		  

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

Re: Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-15 by Donald H

--- In AVR-Chat@yahoogroups.com, Cat C <catalin_cluj@...> wrote:
>
> 
> The watchdog does it's job, it just happens to be the convenient way to have a reset a little while after a power up, if the SPI doesn't work.
> I don't see any other way of "cleaning" the SPI.
> It's not a simple communication timeout, it's a complicated one, and if I have 1000 SPI calls, they will all fail until I do a reset.
> If you're gonna propose a reset chip, or other circuitry to get a reset other ways, why?  This works fine.

This may "fix" your SPI problem, but what other problems will it cause in the future.

I see from the Atmel web site that the ATMega664P has been obsoleted and to use the ATMega664P'A' device.

I would think there is some other problem and this is how it shows itself.

Lets face it, the SPI port should always work and this is just wrong.

If this is for a product and you can not get non'A' versions, what problems will you see then ?

I will be moving from a ATmega16 to a 64K part this summer.

If the 664P is having problems, I don't want to include it in my parts list. ( maybe that why Atmel dis-continued it)

I did not see any errata about SPI or RESET problems.

If a RESET chip will fix this problem, it will be better then waiting for a strange problem to appear in production.

good luck

don

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-15 by Robert Adsett

On 3/14/2010 8:58 PM, Cat C wrote:
> If you're gonna propose a reset chip, or other circuitry to get a reset other ways, why?  This works fine.

I would recommend at least testing with a proper reset chip.

Why?  Simply to try to narrow down the problem.  Problems like this 
worry me, they indicate something going on that is not understood. Such 
things have a nasty habit of coming back in another form avoiding the 
initial workaround.

This 'feels' like a power on reset problem and built-in micro-controller 
power on reset circuits are notorious for having holes in some corner of 
performance.  An external reset chip would eliminate that possibility. 
Leaving a reset chip in the design is open to question, testing with a 
reset chip at his point I would consider mandatory.

My other immediate suspicion in cases like this is initialization code. 
  Although given your experience with this processor family I cannot 
imagine what you could be leaving out (and I have no suggestions to offer).

My best suggestion is to be worried.

Robert



-- 
  From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time?  37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live....
we currently have stock."

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-15 by enkitec@gmail.com

On 15-Mar-10 00:11, Robert Adsett wrote:
>
> My other immediate suspicion in cases like this is initialization code.
> Although given your experience with this processor family I cannot
> imagine what you could be leaving out (and I have no suggestions to offer).
>
> My best suggestion is to be worried.
> Robert
>    


     Maybe insert some delay just after reset, before the initialization 
code.
     I have seen weird things happening after power on.
     They all disapear if I wait some 100mS to initialize the chip.

     Mark Jordan

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)

2010-03-15 by Jim Wagner

On Mar 14, 2010, at 8:11 PM, Robert Adsett wrote:

> On 3/14/2010 8:58 PM, Cat C wrote:
> > If you're gonna propose a reset chip, or other circuitry to get a  
> reset other ways, why? This works fine.
>
> I would recommend at least testing with a proper reset chip.
>
> Why? Simply to try to narrow down the problem. Problems like this
> worry me, they indicate something going on that is not understood.  
> Such
> things have a nasty habit of coming back in another form avoiding the
> initial workaround.
>
> This 'feels' like a power on reset problem and built-in micro- 
> controller
> power on reset circuits are notorious for having holes in some  
> corner of
> performance. An external reset chip would eliminate that possibility.
> Leaving a reset chip in the design is open to question, testing with a
> reset chip at his point I would consider mandatory.
>
> My other immediate suspicion in cases like this is initialization  
> code.
> Although given your experience with this processor family I cannot
> imagine what you could be leaving out (and I have no suggestions to  
> offer).
>
> My best suggestion is to be worried.
>
> Robert
>
>
> 

I agree with Robert. While watchdog reset may "work", to me, it is  
indicative that something is wrong. Wrong because it should not be  
needed and because there are many,. many, apps out there, that do fine  
without resorting to it. The fact that all this is necessary indicates  
to me that there is something happening that is unrecognized, not  
understood, etc. If this is the case, then you do NOT know what else  
is happening or what else might happen. Watchdog may "fix" the "hung  
SDI" problem, but what about the other, so far unrecognized things?  
And, program complexity is only an excuse for not solving it. There  
should be NO reason for a complex program to have this problem than a  
simple one, other than the fact that it is harder to debug.

I have been through situations roughly like this. They were always  
painful to dissect and always took an inordinate amount of time. But,  
every one had other problems besides the one that was the most  
obvious. Sometimes, they were errors like an interrupt happening in  
the middle of what SHOULD have been an atomic operation. Sometimes,  
they were mis-configured hardware. Sometimes, it was code that  
attempted to follow an incorrect understanding of how some bit of  
hardware really works. Occasionally, it was a state machine with an  
incorrect state name used at some point in the machine. But, every one  
was really, really, obscure.

I hope you take time to work it out. Frankly, I would not trust  
operation of the device, left as it is.

Jim Wagner
Oregon Research Electronics




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

RE: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P) SOLVED!!!

2010-03-15 by Cat C

Thank you Bruce!

That was IT (I think you mean SS though)!

It's amazing how... little things like this mess things up, and how lucky that you happened to look into this!

I still don't understand why it happens, as I enable the SPI port after a long delay (even tried 1s) so the voltage should be stable by then.
Should I have seen this from somewhere in the Datasheet?

Thanks again,

Cat

> To: AVR-Chat@yahoogroups.com
> From: obparham@jpl.nasa.gov
> Date: Mon, 15 Mar 2010 10:40:05 -0700
> Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)
> 
> Hi Cat,
> 
> This may have already been asked and I missed it but, in your 
> initialization code, do you
> set the CS pin to OUTPUT before or after you enable the SPI port? If 
> it's done after, an
> initial low voltage on the pin may be forcing the SPI port into slave 
> mode as soon as it's
> enabled.
> 
> Bruce

 		 	   		  

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

Re: Code stuck waiting for SPI transmission but only after power-up. (ATMega644P) SOLVED!!!

2010-03-15 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, Bruce Parham <obparham@...> wrote:
> The data sheet just says, if it's an input, it should be high to
> keep the port in master mode.
If the SS pin doesn't have a pullup on it, it could be floating low enough to trigger the Master-to-Slave transition between the time when the controller is enabled and the SS bit is made an output.

In any event, it is best to set the SS pin direction and state *before* enabling the controller as Bruce advised.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P) SOLVED!!!

2010-03-15 by Bruce Parham

Cat C wrote:
> Thank you Bruce!
>
> That was IT (I think you mean SS though)!
>   
Sorry yes, SS (Slave Select). It been a while since I looked at the data 
sheets.
> It's amazing how... little things like this mess things up, and how lucky that you happened to look into this!
>
> I still don't understand why it happens, as I enable the SPI port after a long delay (even tried 1s) so the voltage should be stable by then.
>   
Don't know, there may be some extra edge detect logic on that pin that 
starts up
in the triggered state and gets cleared when the direction register bit 
is set. The data
sheet just says, if it's an input,  it should be high to keep the port 
in master mode.
> Should I have seen this from somewhere in the Datasheet?
>   
The *SPI /SS Pin Functionality/* section talks about it but does not say 
anything
about initialization. (This is from an ATMega644 data sheet; I assume 
'644Ps and
later are the same...)
> Thanks again,
>
> Cat
>   
You're welcome, glad to help.

Bruce
Show quoted textHide quoted text
>> To: AVR-Chat@yahoogroups.com
>> From: obparham@jpl.nasa.gov
>> Date: Mon, 15 Mar 2010 10:40:05 -0700
>> Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)
>>
>> Hi Cat,
>>
>> This may have already been asked and I missed it but, in your 
>> initialization code, do you
>> set the CS pin to OUTPUT before or after you enable the SPI port? If 
>> it's done after, an
>> initial low voltage on the pin may be forcing the SPI port into slave 
>> mode as soon as it's
>> enabled.
>>
>> Bruce
>>

Re: Code stuck waiting for SPI transmission but only after power-up. (ATMega644P) SOLVED!!!

2010-03-16 by _wsw_

Maybe the application note "AVR151-Setup and use of the SPI" would be of interrest? There is a whole chapter about the SS pin behaviour...

Stefan

--- In AVR-Chat@yahoogroups.com, Cat C <catalin_cluj@...> wrote:
Show quoted textHide quoted text
>
> 
> Thank you Bruce!
> 
> That was IT (I think you mean SS though)!
> 
> It's amazing how... little things like this mess things up, and how lucky that you happened to look into this!
> 
> I still don't understand why it happens, as I enable the SPI port after a long delay (even tried 1s) so the voltage should be stable by then.
> Should I have seen this from somewhere in the Datasheet?
> 
> Thanks again,
> 
> Cat
> 
> > To: AVR-Chat@yahoogroups.com
> > From: obparham@...
> > Date: Mon, 15 Mar 2010 10:40:05 -0700
> > Subject: Re: [AVR-Chat] Code stuck waiting for SPI transmission but only after power-up. (ATMega644P)
> > 
> > Hi Cat,
> > 
> > This may have already been asked and I missed it but, in your 
> > initialization code, do you
> > set the CS pin to OUTPUT before or after you enable the SPI port? If 
> > it's done after, an
> > initial low voltage on the pin may be forcing the SPI port into slave 
> > mode as soon as it's
> > enabled.
> > 
> > Bruce
> 
>  		 	   		  
> 
> [Non-text portions of this message have been removed]
>

RE: [AVR-Chat] Re: Code stuck waiting for SPI transmission but only after power-up. (ATMega644P) SOLVED!!!

2010-03-16 by Cat C

AAAAARGGGHHHH!
Application Notes: is there anything they can't do?

I'll be sure to read it when I have some time, right now I have to make up the lost time.

Thank you Stefan.

Cat

> To: AVR-Chat@yahoogroups.com
> From: yahoo@wsw-elektronik.de
> Date: Tue, 16 Mar 2010 19:44:38 +0000
> Subject: [AVR-Chat] Re: Code stuck waiting for SPI transmission but only after power-up. (ATMega644P) SOLVED!!!
> 
> Maybe the application note "AVR151-Setup and use of the SPI" would be of interrest? There is a whole chapter about the SS pin behaviour...
> 
> Stefan
> 

 		 	   		  

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

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.