[Solved] ForLoopIteration from Arduino IDE Examples for Atmega1284P question

I am using AVR Dragon in Atmel Studio 7. I have no problem building then programming to any Arduino Uno 328P or Arduino Mega(adk) using AVR Dragon in Atmel Studio 7. If I try and program this to an Atmega1284P it builds and programs the chip fine but the chip is not outputing anything to the pins as it suppose to. I guess I could use Arduino IDE with an Arduino Uno ISP and program the Atmega1284P chip that way, but there is no choice for Atmega1284P as for as I know? I would still like to get this to work in both Arduino IDE and Atmel Studio 7. It seems I cannot win here because if I use Arduino IDE I cannot use AVR Dragon or AVRISP MKII, and if I use Atmel Studio 7 I cannot use an Arduino Uno or Mega to program the Atmega1284P so I have one major dilemma!!

Actually there is a thread on how to get the Atmel AVRISP MKII to work in Arduino IDE which I will have a look into later but for now if anyone can help resolve why this code will not work on an Atmega1284P it would be greatly appreciated.

I tested a simple blink program and it runs fine but the ForLoopIteration does not?

Simple Blink works fine for Atemga1284P:

/*
 * SimpleBlink.c
 *
 * Created: 4/22/2016 9:46:36 PM
 * Author : pcfr33k
 */ 


#define F_CPU 8000000

#include <avr/io.h>
#include <util/delay.h>


int main(void)
{
 DDRB |= (1 << PINB0);
 PORTB &= ~(1 << PINB0);
    while (1) 
    {
 PORTB ^= (1 << PINB0);
 _delay_ms(300);
    }
}

ForLoppIteration not working in Atmega1284P

/*Begining of Auto generated code by Atmel studio */
#include <Arduino.h>

/*End of auto generated code by Atmel studio */


//Beginning of Auto generated function prototypes by Atmel Studio
//End of Auto generated function prototypes by Atmel Studio

/*
  For Loop Iteration

 Demonstrates the use of a for() loop.
 Lights multiple LEDs in sequence, then in reverse.

 The circuit:
 * LEDs from pins 2 through 7 to ground

 created 2006
 by David A. Mellis
 modified 30 Aug 2011
 by Tom Igoe

This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/ForLoop
 */

int timer = 100;           // The higher the number, the slower the timing.

void setup() {
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 2; thisPin < 8; thisPin++) {
    pinMode(thisPin, OUTPUT);
  }
}

void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 2; thisPin < 8; thisPin++) {
    // turn the pin on:
    digitalWrite(thisPin, HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(thisPin, LOW);
  }

  // loop from the highest pin to the lowest:
  for (int thisPin = 7; thisPin >= 2; thisPin--) {
    // turn the pin on:
    digitalWrite(thisPin, HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(thisPin, LOW);
  }
}

Thanks

ForLoppIteration not working in Atmega1284P

What does "not working" mean exactly ?
How you tried printing the value of relevant variables at pertinent points in the program ?

As Atmel studio supports all current Atmel chips (not just the AVR's) it's clear you are doing something wrong!

The second thing you have done wrong is to ask here, where 99% of people use the Arduino IDE.

Try reading the Atmel documentation!

Mark

And please edit your Original Post and put Atmega 1284P in the title so those of us who know nothing don’t waste our time opening your Thread.

…R

UKHeliBob:
What does "not working" mean exactly ?
How you tried printing the value of relevant variables at pertinent points in the program ?

I thought I was clear on that but I forgot to mention this. I am getting no output or pattern from the LEDs. I just wanted this sketch to work on a 1284P. Is there a way to convert it from Arduino IDE to Atmel Studio 7 code and vice versa?

I guess my post is not clear. Besides trying to figure out what needs to be fixed in the code for Atmel Studio, I basically want to know how I can use Sketch's from Arduino IDE into Atmel Studio and vice versa since some hardware cannot be used in one or the other. I have read the documentation and like I said if you read it clearly I have gotten the blink program to work on both the Atmega 328P and Atmega1284P using either the Atmel Studio 7 or Arduino IDE with either the Arduino Mega(adk) board or AVR Dragon board.

So I think its fair to post this here and I will consider posting over in the Atmel forums as well.

Thanks

Can I suggest that you break the problem down. You say that the for loop does not work but how do you know that ? What do you see if you print the value of the for loop variable inside the loop ?

Which Arduino board are you using ?

UKHeliBob:
Can I suggest that you break the problem down. You say that the for loop does not work but how do you know that ? What do you see if you print the value of the for loop variable inside the loop ?

Which Arduino board are you using ?

After I program the Atmega1284P chip from the AVR Dragon I place it on a breadboard with all appropriate caps/resistors and connections. I also use a Cheap Developmental board with Ziff socket which makes things easier because it comes with all the proper connections and circuits so all I have to do is jumper pins from that board to a breadboard that has the LEds inserted.

So instead of placing the 1284P chip on a breadboard I can place it in this and then jumper the wires.

And forgot to connect the grounds!

Mark

holmes4:
And forgot to connect the grounds!

Mark

Nope all connections are made correctly. I also use these to power the devices and negative to the breadboard for the LEDs and leads from resistor to the pins on that device. Positive/negative from the power adapter to the device and negative from the power adapter to the breadboard negative LED side. As in my OP I am able to run this no problems with a 328P setup the same way but with a different device. That one I posted is not for the 328P and I use the same power adapter.

Edited 4-24-16:

I have tried every possible way and combinations of different hardware (more than one can count) and configurations and its just not going to work because the 1284P is not in the list of supported hardware in Arduino IDE. Maniacbug has released a package for Arduino IDE but for older versions. I will have to take the code and do some conversations in Atmel Studio 7 then I will be able to upload it to the 1284P with AVR Dragon, AVRISP MKII, etc. Is there any reason why the 1284P is not supported in Arduino IDE?

Edited 4-29-2016.

Completely Solved with the most amazing support I have had in the last 30 years of being on forums!!

http://www.visualmicro.com/forums/YaBB.pl?num=1461774686