Clocking / Memory problems with MEGA1284P

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

I'm running into an issue while trying to migrate from a MEGA644P to a MEGA1284P. I'm seeing strange corruption problems when serial input is fed into the chip, even when the USART is not enabled. It seems to closely related to the problem discussed here: http://www.seanet.com/~karllunt/1284pmemprob.html
On that page, the problem was determined to be pre-production chips, but I'm seeing it with 1017 date codes.

The problem only occurs with 1284P DIP chips and a 20MHz crystal (with 18pf caps), and a rising edge on RX0. Swapping to the 644P works, a slower crystal (3.5MHz) works, an external 20MHz clock oscillator works, a surface mount 1284P works. It fails on 1284Ps with 3 different date codes (all I had) and on 3 different PCBs, plus a simplified protoboard I built and all the fuse settings I could try. It fails with sending in slow serial from a MAX232 chip, or even just brushing a wire between RX0 and VCC.

Atmel claims that the input to RX0 in interfering with the clock line, and that that is happening outside the chip, but I think it may be inside the chip. The recommend solution was to add a series resistor and cap to the RX0 line, but that doesn't help me migrate all my existing socketed 644P chips.

I've narrowed down to the code below that exhibits the problem (the output pin flashes when it never should) when the RX0 line receives serial data (or any low to high transition).

One interesting thing I found is that if you remove one of the nop()s, the problem goes away, and if you remove both, it comes back. So the problem seems to be code location related, like it only hits on even
or odd addresses.

#include 

#define nop()  __asm__ __volatile__("nop")

volatile unsigned char count1;
volatile unsigned char count2;

int main( void )
{
       nop();
       nop();

       DDRB |= 1<<3;
       count1 = 0;
       count2 = 0;

       while ( 1 )
       {
               count1++;
               count2++;
               if ( count1 != count2 ) {
                       PORTB ^= 1<<3;  // Should never happen, but it does!
               }
       }

       return 0;
}

Here is the simplified protoboard I made to show the problem :

For this protoboard, I modified the code slightly to add a heartbeat LED. When I fed in a 10MHz oscillator to RX0, I could even get the chip to hang.

Any hints or suggestions? Can others reproduce this? Should all inputs always have a serial resistor and capacitor?

Thanks for your help,
Byon

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

Is no one doing serial on a DIP 1284s with a 20MHz crystal? I'd really like to hear from you if you are.

If you are using a 324 or 644 chip, perhaps I can send a 1284 to test.

I'd really like to figure this out.

thanks!

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

I use 324 and 1280 in TQFP on double side boards. I run the 324 at 18.432, works great. I run the 1280 at 14.7456, runs great, all 4 uarts. Try hooking up AVCC and the other gnd. Put the caps right on the VCC and gnd pins.

Imagecraft compiler user