Static RAM reads incorrectly

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Am pulling my hair out for 2 days on this issue - appreciate ANY help or experiments-to-try as I'm currently out of ideas.

 

Won't bore you with details, but I'm building large VU-meters, and I've found a point in my code where I read RAM and it's not what was stored there, breaking all the ensuing logic of course.

 

Attached is a screenshot of AVR Studio, showing the code snippet where I'm having the trouble.  I'm connected to the ATMega1284 via JTAG.  In this short snippet, I try 3 different set of instructions to read RAM address $010D and $010E.  All come back with values that don't match the $3F, $F7 actually stored there. 

 

Some things I've done:   

1) all interrupts disabled and I am single-stepping anyhow

2) ATMega1284 on external 20mhz crystal - also tried with Div8 fuse on (2.5mhz) and still have the problem

1) tried 4 processors - all have same problem, 

2) set BOD=2.7v and 5v supply is very clean at 5.05v, 

3) verified ground to processor is good,  

4) tried Simulator and it shows RAM reading correct values

5) checked for any Atmel-errata or board discussion here - none.

 

I've used the ATMega1284 for 5-6 other projects and haven't run into such a problem.

 

Thanks in advance for any ideas.

 

-mark

Attachment(s): 

Mark
Elgin, IL (near Chicago)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

WHOA !   .....    I just retried the Div8 on the clock, and at 2.5mhz the ATMega1284 RAM does read correctly.   I must have made a mistake in trying that previously.

 

So it does seem the processor isn't reliably accessing RAM at 20mhz, although it is spec'ed to run that fast.  

 

Appreciate any thoughts.   

Mark
Elgin, IL (near Chicago)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So, you are talking about internal SRAM?  I doubt very much if the AVR has problems per se with speed and internal SRAM operations.

 

Decoupling caps?

 

Re errata, that model does have "idiosyncrasies" with max clock rate and USART.

 

What about at /2 (CLKPR)?

 

Aren't some of the Arduino models '1284 based?  Surely if there was an SRAM problem it would be well known?  (but they usually run at 16MHz, don't they?)

 

As usual, post the smallest complete test program that demonstrates the symptoms.  Show schematic.  Run that program on your "working" '1284 boards--what result?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

fmr300 wrote:

 

I've used the ATMega1284 for 5-6 other projects and haven't run into such a problem.

 

Thanks in advance for any ideas.

 

-mark

 

I haven't had any problems with that chip either, even at 22.1184mhz and 24mhz.

 

Are you using a uart as a slave connection?

 

I have heard some have had problems with uart0 since it's right next to the crystal pins and there could be some coupling between pins when using low power oscillator mode.

Just make sure to keep the wires/traces from the uart0 pins away from the crystal pins (ALWAYS keep crystal/caps leads short as possible) or use full swing oscillator mode and maybe even use uart1 instead.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hallo Mark

 

It may be a stack problem  ?

 

Link: http://www.avr-asm-tutorial.net/...

Link: http://www.avrbeginners.net/arch...

 

SRAM: 

 

Greetings Rolf

Windows 10 Home 64Bit, ASUS M4A89GTD-PRO/USB3, AMD Phenom II X6 1055T, Ram 2x 4GB, SSD Samsung EVO840 250GB, SATA HD 2.0TB, NVIDIA GeForce GTX 750

Last Edited: Sun. May 24, 2015 - 10:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ot might be an atomicity problem. Running at a higher speed makes it happen more often.
I'd be digging a bit deeper to find the root cause.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've looked a little more and it's really bizarre.  

 

Attached is a screenshot and since someone asked, a schematic.

 

I've trimmed the test program to just a few lines:   write to two RAM locations, then read them back.

 

At 20mhz, it can pass or fail, depending on how many instructions run before the RAM test !   Take a look at this short program please - if I add NOP's up front, the number of NOP's added will determine the pass/fail.

 

The screenshot is of a failure.  You can see in the Data-view window what the RAM has, and you can see in the X, Y registers what my program reads back.   They match if there are an even number of NOP's, and they mismatch with an odd number of NOP's.

 

And all tests pass at 2.5mhz clock.  I'm tempted to try 16mhz next, but really need 20mhz for this particular project....

 

But if RAM is having a problem at 20mhz, why can the Dragon always read it correctly over JTAG ?    Arrrgggghhhh....   really appreciate you guys ideas/comments!!

Attachment(s): 

Mark
Elgin, IL (near Chicago)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

fmr300 wrote:

 

At 20mhz, it can pass or fail, depending on how many instructions run before the RAM test !   Take a look at this short program please - if I add NOP's up front, the number of NOP's added will determine the pass/fail.

 

 

 

It seems like the start up time for the crystal (or is it a resonator?) is slow or some other stability problem. Have you tried using different clock fuse settings?

 

edit: added check clock fuses

Last Edited: Mon. May 25, 2015 - 03:30 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you tried full swing oscillator mode yet (as has already been suggested)?

 

By the way, it's probably not SRAM which is failing, but the register file itself.

 

The 1284 has a known issue with high-slew-rate signals on RXD0 when using low-power oscillator mode.  Either stop using RXD0, or limit the slew rate on it with an RC filter, or use full-swing oscillator mode.

 

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Mon. May 25, 2015 - 04:05 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But if RAM is having a problem at 20mhz, why can the Dragon always read it correctly over JTAG ?

Let's see. Obviously there is more to the program that what you are showing in the screen shot otherwise it would be a useless program.

 

Does the problem happen at power up? You say that "the Dragon always read it correctly over JTAG" which means that the chip is working correctly.

 

If it happens at power up then make sure you have the BOD set at the highest level possible for your VCC. Also make the SUT as long as possible (64ms??)

 

Humans don't feel to comfortable doing anything the instant they first wake up, micros are the same.....don't know what the equivalent of an espresso coffee is for micros but the above is pretty close.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

RESOLVED !!!!!!!

 

I'm not (yet) using RxD0, so I had somewhat discounted the low-power oscillator problem in conjunction with RxD0 as a root-cause.  Was about to try it anyhow, when I also noticed that I had just a wee bit of jitter on my 20mhz ClockOut pin.  Probably double-clocking due to noise at the transitions, causing bad hi-speed clocks.

 

Tried the full-swing oscillator and the problem is gone.

 

I hit a brick wall on this, and may not have thought of this oscillator-swing for quite some time, had it not been for the help from this board.  Honestly, I can't hardly express my full gratitude sufficiently.   I was already at a point where I needed to walk away from my bench before I started smashing things!  :^)

 

theush, ront1234, kartman(atomicity???), rolfdegen, joeymorin, js  -  THANK YOU and if in Chicago you can get a free beer anytime by contacting me:  fmr300@yahoo.com

 

-mark

Mark
Elgin, IL (near Chicago)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

How many threads like this one have we seen? I think Atmel should modify the 1284 datasheet to put a huge warning about the clock on page 1.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

 

How many threads like this one have we seen? I think Atmel should modify the 1284 datasheet to put a huge warning about the clock on page 1.

I've responded to these suggestions before.  My take:  "Sure.  Now, tell which information in the 500+ page datasheet is NOT important enough to not highlight?"

 

Won't nearly any setting have the possibility to cause puzzling operation?:

 

When you decide to apply a 20MHz crystal and look that up in the datasheet, doesn't it tell you to use full-swing?  (Or at least suggest it?)

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

True bit the fact that 1284 is so more sensitive to the lack of full swing catches more than other AVRs. (the "bit" at the start of this should be "but", unfortunately this crap editor won't let me position the cursor at the start of the line to correct it)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I repeat:  Exactly what parameters and setting in the datasheet are NOT important enough to be bolded on page 1?

 

If I am putting together a system with that model and a 20MHz crystal, then I look in the datasheet (for the clock fuse combination) and what do I find?

 

9.3 Low Power Crystal Oscillator
This Crystal Oscillator is a low power oscillator, with reduced voltage swing on the XTAL2 out-put. It gives the lowest power consumption, but is not capable of driving other clock inputs, and may be more susceptible to noise in noisy environments. In these cases, refer to the ”Full swing Crystal Oscillator” on page 34.

 

 

Do you see 20MHz on that list?

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.