'1284P pullup resistor error

Just discovered this problem from a 1284 user - any one else seen this?
Simple sketch:

byte sample;

void setup(){
  pinMode (2, INPUT_PULLUP);
}
void loop(){
  sample = digitalRead(2);
}

Result:

C:\Arduino-1.0.5\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega1284p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -IC:\Arduino-1.0.5\hardware\mighty-1284p\cores\standard -IC:\Arduino-1.0.5\hardware\mighty-1284p\variants\standard C:\Users\Owner\AppData\Local\Temp\build596662852053671211.tmp\sketch_dec13a.cpp -o C:\Users\Owner\AppData\Local\Temp\build596662852053671211.tmp\sketch_dec13a.cpp.o
sketch_dec13a.ino: In function 'void setup()':
sketch_dec13a:4: error: 'INPUT_PULLUP' was not declared in this scope

Compiling for my Sanguino I don't get that message. Sounds like his core files might be out of date.

Mine do the same thing tho. Thinking it's something in the mighty1284 files.

Just downloaded the mighty1284 files into a fresh 1.0.5.
Same result.

maniacbug-mighty-1284p-68ed99c.zip (128 KB)

pins_arduino.h (6.26 KB)

Just downloaded the mighty1284 files into a fresh 1.0.5.
Same result.

compiling in any old Arduino version helps? like the Arduino 1.0 perhaps!

Crossroads I made your piano, and received the same error when I tried to change these lines:

 for (x=0; x<14; x=x+1){ // input pins with pullup
    pinMode(keyArray[x], INPUT);
    digitalWrite (keyArray[x], HIGH);
  }

to this:

 for (x=0; x<14; x=x+1){ // input pins with pullup
    pinMode(keyArray[x], INPUT_PULLUP);
   }

Side note: Also, couldn't get your piano to work correctly when I used the Atmega_Board_Programmer linked on Nick Gammon's Minimal Board page.
Had to use your ATmegaBOOT_1284P_16MHz.hex file.

Interesting developments.
Can you post the boot file here? I have a new laptop and only have the original mighty1284 boot files.

It's attached.

ATmegaBOOT_1284P_16MHz.hex (5.5 KB)

It's because the 1284 core doesn't define INPUT_PULLUP because it's based on the Arduino core prior to that change.

From memory I came across this once and added an extra define near INPUT and OUTPUT IIRC

#define INPUT_PULLUP 0x02

I can't confirm at the moment as haven't got access to the files.

What did you add that into? One of the core files?

This is where I had the issue and it was discussed :-

http://forum.arduino.cc/index.php?topic=142041.0

I originally did a manual fix, but then lefty pointed out that he had copied arduino.h and wiring.c from a newer Arduino core to his 1284P core, so I can't remember if I then did the same as well.

The manual fix involved modifying both files to first define the new mode and then add the new mode so that the single option then makes the pin INPUT and sets it HIGH, which is what INPUT_PULLUP does in a single IDE instruction.

Either fix should make INPUT_PULLUP work properly on 1284 cores anyway

I changed mighty1284/cores/standard/Arduino.h, and INPUT_PULLUP commands compile now.
I didn't see anything to change in wiring.c

Arduino.h (5.5 KB)

Sorry, it is wiring_digital.c, in the pinMode function

Read the link I posted CrossRoads. If you added the define in Arduino.h then it will compile but it won't actually do what it's supposed to do. It will just satisfy the 'else' part in the pinMode function and using INPUT_PULLUP would set the pin to OUTPUT. You have to add the extra part to set the registers for INPUT and HIGH.

Change

	if (mode == INPUT) { 
		uint8_t oldSREG = SREG;
                cli();
		*reg &= ~bit;
		SREG = oldSREG;
	} else {
		uint8_t oldSREG = SREG;
                cli();
		*reg |= bit;
		SREG = oldSREG;
	}

To

        if (mode == INPUT) { 
		uint8_t oldSREG = SREG;
                cli();
		*reg &= ~bit;
		*out &= ~bit;
		SREG = oldSREG;
	} else if (mode == INPUT_PULLUP) {
		uint8_t oldSREG = SREG;
                cli();
		*reg &= ~bit;
		*out |= bit;
		SREG = oldSREG;
	} else {
		uint8_t oldSREG = SREG;
                cli();
		*reg |= bit;
		SREG = oldSREG;
	}

Okay, got that one changed now. Wil try it this afternoon as we wait out the 8-10" snowstorm that's starting this afternoon.

I did read that whole thread, looking at the wrong file for the 2nd set of changes was the part that got me.

CrossRoads:
Okay, got that one changed now. Wil try it this afternoon as we wait out the 8-10" snowstorm that's starting this afternoon.

I did read that whole thread, looking at the wrong file for the 2nd set of changes was the part that got me.

Sorry about that. My fault for misdirecting you to wiring.c instead of wiring_digital.c

I was initially working from what i was trying to remember. I knew it had 'wiring' in it. :stuck_out_tongue:

I'm having the same problem so I will try the updates as well.

Does anyone know if the mighty1284 core is still being updated? It seems like a while since the last release. So far I am pleased with the core and the 1284 rocks.

Haven't seen maniacbug post here in a while.

CrossRoads:
Haven't seen maniacbug post here in a while.

478 days ago ... :astonished: Looks like his blog was last updated about the same time ... :astonished: :astonished: :astonished:

That's quite a while. He's been active in the past few months on GitHub, but on other products.

I found a fork with the fix included here:

However, I don't see a pull request, so I can't tell if one wasn't made or if maniacbug no longer maintains the Mighty core.

Would it be worth it to start maintaining a fork and see if maniacbug returns and pulls the changes? This is new grounds for me, but I am willing to maintain updates on the chip. I have two really interesting projects that I am about to dive into, so I will be tied to the 1284 for at least 6 months. The proto boards arrive tomorrow....I can't wait!