Go Down

Topic: '1284P pullup resistor error (Read 934 times) previous topic - next topic

CrossRoads

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

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

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.

Nick Gammon

Compiling for my Sanguino I don't get that message. Sounds like his core files might be out of date.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

CrossRoads

Mine do the same thing tho. Thinking it's something in the mighty1284 files.
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.

CrossRoads

Just downloaded the mighty1284 files into a fresh 1.0.5.
Same result.
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.

NI$HANT

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!
"Real Men can Accomplish  Anything"
- <a href="http://www.winacro.com">  <b><font color="red">Website</font></b> </a> 
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੁਂ!

elac

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

to this:
Code: [Select]
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.
It's all about the skills

CrossRoads

Interesting developments.
Can you post the boot file here? I have a new laptop and only have the original mighty1284 boot files.
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.

elac

It's all about the skills

tack

#8
Dec 13, 2013, 04:37 pm Last Edit: Dec 13, 2013, 04:41 pm by tack Reason: 1
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: [Select]

#define INPUT_PULLUP 0x02


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

CrossRoads

What did you add that into? One of the core files?
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.

tack

#10
Dec 14, 2013, 01:09 am Last Edit: Dec 14, 2013, 01:17 am by tack Reason: 1
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

CrossRoads

I changed mighty1284/cores/standard/Arduino.h, and INPUT_PULLUP commands compile now.
I didn't see anything to change in wiring.c
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.

tack

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: [Select]
if (mode == INPUT) {
uint8_t oldSREG = SREG;
               cli();
*reg &= ~bit;
SREG = oldSREG;
} else {
uint8_t oldSREG = SREG;
               cli();
*reg |= bit;
SREG = oldSREG;
}


To

Code: [Select]
       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;
}

CrossRoads

#13
Dec 14, 2013, 03:16 pm Last Edit: Dec 14, 2013, 03:18 pm by CrossRoads Reason: 1
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.
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.

tack


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. :P

Go Up