system
June 21, 2008, 7:47pm
1
Problem is that there is external equipment (LCD in this case) that really doesn't like getting double initialized once it is powerd up. So you reporgram the duino or reset it or open a comm connection to it and the lcd goes haywire. I have a temporary fix by powering the LCD controller with an arduino pin, but I want my pin back.
So has anyone heard of a way to tell that a reset just occured and not a power up?
system
June 22, 2008, 4:08am
2
I'm pretty sure a Powerup and a Reset are the same thing as far as the ATMega's concerned.
Easiest solution I see would be to get a Programmer, and ditch the Arduino bootloader.
Then it won't pulse your pins when it powers up.
system
June 22, 2008, 11:25am
3
So has anyone heard of a way to tell that a reset just occured and not a power up?
According to the ATmega168 data sheet (page 54) there is a register that tracks this: MCUSR – MCU Status Register
The MCUSR can differentiate between Power-on Reset and External Reset (among others).
Here's an Arduino-related use of the MCUSR: Arduino Hacks
A hardware thought, could you hook the reset line to also trigger a LCD reset?
--Phil.
system
June 22, 2008, 6:45pm
4
Note that if you're using an Atmega8 instead of Atmega168, the register is MCUC SR (Atmega168 is MCUSR). And the page for the Atmega8 datasheet is 41.
system
June 22, 2008, 10:42pm
5
SWEET!!! Thanks guys!! I will definately give that MCUSR a shot. I saw a lot of stuff in the data sheet and couldn't quite make sense of all of it.
system
June 23, 2008, 12:47am
6
Working good, thx again
void setup(){
int po = MCUSR;
MCUSR=0;
pinMode (13,OUTPUT);
if(po & 1)
digitalWrite(13,HIGH); //or call lcd.init()
}
void loop(){}
system
June 23, 2008, 6:49am
7
void setup(){
int po = MCUSR;
MCUSR=0;
pinMode (13,OUTPUT);
if(po & 1)
digitalWrite(13,HIGH); //or call lcd.init()
}
void loop(){}
Thanks for completing the circle and posting your code.
Note that if you're using an Atmega8 instead of Atmega168, the register is MCUC SR (Atmega168 is MCUSR). And the page for the Atmega8 datasheet is 41.
Ditto for the ATmega128 which I had noticed.
--Phil.