Pages: [1] 2   Go Down
Author Topic: '1284P pullup resistor error  (Read 614 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 513
Posts: 26247
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

void setup(){
  pinMode (2, INPUT_PULLUP);
}
void loop(){
  sample = digitalRead(2);
}
Result:
Quote
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
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 473
Posts: 18695
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 513
Posts: 26247
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 513
Posts: 26247
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

* maniacbug-mighty-1284p-68ed99c.zip (128.17 KB - downloaded 5 times.)
* pins_arduino.h (6.26 KB - downloaded 5 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1573
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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!
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

Connecticut, USA
Offline Offline
Full Member
***
Karma: 8
Posts: 180
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Crossroads I made your piano, and received the same error when I tried to change these lines:
Code:
for (x=0; x<14; x=x+1){ // input pins with pullup
    pinMode(keyArray[x], INPUT);
    digitalWrite (keyArray[x], HIGH);
  }
to this:
Code:
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.
Logged

It's all about the skills

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 513
Posts: 26247
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Connecticut, USA
Offline Offline
Full Member
***
Karma: 8
Posts: 180
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's attached.

* ATmegaBOOT_1284P_16MHz.hex (5.5 KB - downloaded 6 times.)
Logged

It's all about the skills

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
#define INPUT_PULLUP 0x02

I can't confirm at the moment as haven't got access to the files.
« Last Edit: December 13, 2013, 10:41:48 am by tack » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 513
Posts: 26247
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: December 13, 2013, 07:17:53 pm by tack » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 513
Posts: 26247
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 - downloaded 9 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

To

Code:
       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;
}
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 513
Posts: 26247
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 14, 2013, 09:18:21 am by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley-razz
Logged

Pages: [1] 2   Go Up
Jump to: