Serial.Print(MCUSR);
Sorry for the confusion.Morning Guys
to be honest im more confused because this war of informations
finally i will try the method Klaus was suggested to read the MCUSR at the startup of the code
then after solving my first issue (knowing the reset source)i will try the rest in case of power loose
thanks
Johnny
--- Updated ---
it was nice to check this when looking for reading the MCUSR register
How to distinguish between ‘reset’ and ‘real power loss’??
I think if you look at the interrupt types, you can differentiate between a Reset interrupt and a power loss/brown out detection interrupt. Table 12-6 in the datasheet: External Pin, Power-on Reset, Brown-out Reset and Watchdog System Reset Ok, so maybe not! So external circuit is needed...forum.arduino.cc
So MCUSR = 7, then the lower 3 bits set =Hi
im testing the simple method i have found to read the MCUSR now
then i have issues of the bootloader so the result was "0"Code:Serial.Print(MCUSR);
after reading about the bootloader corrupt this registers i have tried to upload the code generated by Arduino without bootloader using my Avrisp programmer
& tried to read the serial
the result was 7 & as i read in the datasheet 7 is the WDIF
what do u suggest to solve this?
thanks
Johnny
thanks Dana i was reading the Avrfreaks post before check your replyThis user seemed to get it working -
MCUSR Register
I'm attempting to write some code so my board knows what type of power up it is experiencing.www.avrfreaks.net
Bootloader and MCU reset register
OK, so this doesn't work: // Adaboot no-wait mod ch = MCUSR; if (!(ch & _BV(EXTRF))) appStart(); MCUSR = 0; The watchdog is still running as the application starts, and resets it after a few ms - causing an endless loop. Page 55 of the datasheet explains why: WDE is overridden by...forum.arduino.cc
Regards, Dana.
seems like no one got this workingThis user seemed to get it working -
MCUSR Register
I'm attempting to write some code so my board knows what type of power up it is experiencing.www.avrfreaks.net
Bootloader and MCU reset register
OK, so this doesn't work: // Adaboot no-wait mod ch = MCUSR; if (!(ch & _BV(EXTRF))) appStart(); MCUSR = 0; The watchdog is still running as the application starts, and resets it after a few ms - causing an endless loop. Page 55 of the datasheet explains why: WDE is overridden by...forum.arduino.cc
Regards, Dana.
seems like no one got this working
i have tested on Arduino IDE & i got 0 as a result for reading MCUSRHi,
I did read the reset source on different AVRs successfully.
I did it like written in post#17.
Did you test it? What happened? How did you test it?
*****
im testing on Arduino uno So im just interested to read the register if i press the Reset button* I don´t know what hardware you use. --> Show your schematic, show a photo of your test circuit.
using Arduino ide & Atmel studio 7 later* I don´t know what compiler/IDE you use. --> Tell us
i have used the UNO bootloader first then used MKII but i didnt change any settings* What upload tool and what setting did you use?
the uno Voltage* What power supply and what voltage do you use?
*****
From my experience:
* Generally it does not matter whether the reset_source_reading_code is in APP section or BOOTLOADER section. But I recommend to do first tests in APP section.
* be sure you use the correct and exact device setup for compiler/IDE/programming tool. Mind that there are ATMEGA328, ATMEGA328P, ATMEGA328PB with (partly) different features. ==> In doubt send a photo.* disable watchdog fuse (at least for the first tests) => set WDTON = 1
* set the BODLEVEL fuses according your supply voltage. --> Tell us your setup
* use the APP section for first tests ==> be sure BOOTRST = 1
* enable the external RESET for first tests: ==> be sure RSTDISBL = 1
* disable debugWIRE interface for first tests: ==> be sure DWEN = 1
* what clock_source do you use ==> show us your Low Fuse Value
* be sure the fuses are programmend correctly (verify, read back)
* don´t use any Lock and Protection features ==> show us your Lock Bit Byte value
* don´t use any interrupt for first tests. ==> Be sure CLI
****
Please check item by item very carefully
Please give detailed feedback
Klaus
I´m not familair with uno. It comes with it´s own power supply? And you don´t know the voltage?the uno Voltage
seems like no one got this working
no one read the MCUSR without problems with or without bootloader
in the datasheet it seems to be easy to read this register
but in real world no one give a good answer of how to read it
hope someone could post a working code of reading this register
with Arduino or Atmel studio or anything works
thanks
Johnny
yes i thought of this for next readingsHi,
Arduino:
* is a big tool. It adds a lot of code to your code. So you can´t be sure it modifies the MCUCSR before you PRINT it.
--> not a reliable test method.
Also my recommendation was to clear the MCUCSR contents after reading. You did not do this. So if if some bits are not cleared by code they will stay SET.
its not reliable method at all All forums talk about bootloaders & methods to try reading this but it fails--> not a reliable test method.
If you want/need to stay with Arduino you need to read Arduino documentation about MCUCSR treatment.
i used to write assmebly code for PIC mcu so i think its the best solution for this*****
Compiled Arduino code, but uploaded via Atmel studio:
* without knowing about fuse setting this also is no reliable test method.
* even if you don´t use the (Arduino) Bootloader does not mean the bootloader does not exist and it does not mean that it is not (partly) executed.
--> thus I asked for fuse setting . You may also upload the used HEX file.
*****
Are you able to write a simple assembler program?
It´s the most focussed and reliable way to debug, because you control every single instruction that will be executed.
working with UNO is much easier & yes it have 5v Regulator inside it*****
I´m not familair with uno. It comes with it´s own power supply? And you don´t know the voltage?
sure i can set fuses im using the default fuses but i was reading about disabling boot section with fuses*****
Although I´m not familiar with Atmel Studio, I´m rahter sure that one can see the fuse setup, modify fuse setup, program or not program fuses... fuses have big influence on behaviour.
--> if you don´t give fuse information, I / we are not able to know the the test conditions.
you help alot but every person have its own way of understandingThus, please answer every single question beginning with post#29 as detailed as possible.
It´s not my intention to keep you busy, I want to quickly find a solution.
Klaus
yes its right--- Updated ---
I guess the key to this is an IDE and programming not using a boot loader, or the modified
Optiboot bootloader -
Need access to MCUSR on atmega2560
Hi jremington! "It is a register, not a flag" Either way: you see that MCUSR is set to Zero in the bootloader. So "Flag" or "Register" does not make a substential difference. I Need the value before it is set to Zero. Best JLforum.arduino.cc
I also saw this -
Optiboot doesn't prevent infinite Watchdog Reset Loop
I think that means that this is neither an optiboot nor a watchdog problem! Probably you have mis-named or left out the ISR() function for the OCR1A interrupt; the compiler fills in all of the vectors that it thinks are "unused" with a jump to "__bad_intrrupt", which reads: 00000930...forum.arduino.cc
Regards, Dana.
Read post #29. I've written one line for every important fuse.what fuses u think i must think of ?
HiRead post #29. I've written one line for every important fuse.
--> For now it's important to read them back and show us.
Klaus
clr R17
in R16, MCUCSR
out MCUCSR, R17
ldi R17, all outputs
out DDRx, R17
out PORTx, R16
loop:
rjmp loop
im planning to use Avrisp & im reading about reuse AssemblyQuestion, do you plan on using a bootloader or ISP ? If bootloader whose
do you plan on using ?
You know the B/L modifying/clearing the flags has been addressed, like OptoBoot,
and their read is shown in this 2018 post -
How to get the cause of reset in arduino uno
Did you research it? Optiboot must be documented...forum.arduino.cc
https://github.com/Optiboot/optiboot/blob/master/optiboot/examples/demo_reset/demo_reset.ino CODE for read
Regards, Dana.
i think it means Enabled or 0Hi,
what does a checked box mean? 1 or 0?
i didnt yetDid you verify them against post#29?
i didnt use Assembly for atmel before but im trying to reuse it******
as already written:
* read MCUCSR (there are several ways, with IN, LD, ...)
* then clear the MCUCSR by writng 0x00
assembler pseudo code:
Code:clr R17 in R16, MCUCSR out MCUCSR, R17 ldi R17, all outputs out DDRx, R17 out PORTx, R16 loop: rjmp loop
No guarantee. Have not used assembler for a long time...
Let´s see what happens.
Klaus
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?