Why will this code work on an ATmega8515 but not ATmega16?

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

I have a program below that will only work when I select ATmega8515 as the target device in AVR Studio4. It works properly for an ATmega8515. However if I install an ATmega16 chip the program will only work if I leave the target device setting as ATmega8515. If I change it to ATmega16 it won't work. Both cases the program will compile properly. It's just when I program the ATmega16 with the target device set to ATmega16 the program doesn't respond. Does any one have any guidance? I wasn't expect this type of version dependance at this level. Thanks.

P.S. I'm using an STK500.

#include 
#include 
#include 
#include 
#include 
#include 
#include 

static volatile uint8_t led;

static void delay(uint16_t us) 
{
    while(us)
    	us--;
}

int main(void)
{   
    DDRB = 0xff;                    // port B output
    
    led = 1;		    //init variable representing the LED state

    while(1)
    {
        if (led)
        {
            led = 0;
            PORTB = 0;
        }
        else
        {
            led = 1;
            PORTB = 0xff;
        }

        delay(50000);
        delay(50000);

    }
}

[/code]

Last Edited: Thu. May 22, 2008 - 02:05 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm surprised it works at all usually that delay() routine would be thrown away by the optimiser which is why are a better option

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

Are you sure that you are not changing the optimization level as well?

Regards,
Steve A.

The Board helps those that help themselves.

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

Tell a bit more about "won't work". Do you install each in its proper socket? Do you only have one AVR mounted at a time? You can, in fact, contact the chip (Mega16) nicely and Read Signature and such?

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

I only have one chip in at a time in their proper sockets. I had gotten the ATmega16 to run a UART program to talk to my Hyperterminal, so I know it's working. The LEDs will blink if I set the target device to ATmega8515 but it won't if I set it to ATmega16.