View previous topic :: View next topic |
Author |
Message |
oszi
Joined: 26 May 2010 Posts: 53
|
Posted: Mon Oct 29, 2012 12:07 pm Post subject: XMega reset status register |
|
|
Hello,
I need to know what was the reason for a reset. Therfore I use this part of code I found from MAK3:
Code: |
Select Case Rst_status 'Rst_status 'Reset Status Register
Case &B0000_0001:
Print #2 , "Power On Reset"
Set Rst_status.0 'clear it
Case &B0000_0010:
Print #2 , "External Reset"
Set Rst_status.1 'clear it
Case &B0000_0100:
Print #2 , "Brown out Reset"
Set Rst_status.2 'clear it
Case &B0000_1000:
Print #2 , "Watchdog Reset"
Set Rst_status.3 'clear it
Case &B0001_0000:
Print #2 , "Program and Debug Interface Reset"
Set Rst_status.4 'clear it
Case &B0010_0000:
Print #2 , "Software Reset"
Set Rst_status.5 'clear it
End Select
|
But it does not work, I allways get a value of '0' for RST_STATUS, equal what kind of reset I'm doing.
What is my fault here?
Thank you |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Mon Oct 29, 2012 7:42 pm Post subject: |
|
|
Where is the rest of the code?
Missing something about reading the mcuscr register, what mcu your using. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
oszi
Joined: 26 May 2010 Posts: 53
|
Posted: Tue Oct 30, 2012 12:42 am Post subject: |
|
|
I'm using a XMega128A1
the rest of the code are more than 7000 lines
Before reading the Rst_status register there are only some const, dim commands.
After that I store the reset status register in a byte
After that I initialize the ports and the LCD
Then I check the content of the stored reset status register --> all times it has '0' equal what reset source I use to generate a reset
the reading of i.e. the OSC status register shows a normal value.
What commands except writing '1' to the several bits and a power on reset makes this register to become '0' ?
Do I have to read another register before or is a special command before reading Rst_status needed?
Thank you |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Oct 30, 2012 10:22 am Post subject: |
|
|
When the chip resets, the status registers with the reset cause bits is saved into register R0.
This is done because the compiler need to reset these flags since otherwise they can not occur again. And before clearing the bits, the status is saved into register R0.
Using the GETREG() function, you can read the cause if there is a need to do so. _________________ Mark |
|
Back to top |
|
|
oszi
Joined: 26 May 2010 Posts: 53
|
Posted: Wed Oct 31, 2012 1:15 am Post subject: |
|
|
Hello Mark,
thank you for your answer. Now it works.
But with your description the example from MAK3 in his first steps would never run, perhaps if you (MAK3) read this here please do an update. When I try something new I always look in the first steps
Is this described in the help? I havn't read something like this.
Are there additional 'spezial functions' of the compiler which need to be known? |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Wed Oct 31, 2012 9:41 am Post subject: |
|
|
MAK3 was a pioneer and made samples before i had a look at those functions. The problem with the reset flag register is that you need to clear it in order that the flag can occur again.
This function was available for normal avr since the begin (only the save to r0 was added later), and i found that for xmega this was not implemented.
So after i added it, this broke MAK3's example.
There is an example that demonstrates it and under config watchdog I have added this info(i could not find it in the help either). I have no idea where a user would look for this info so if you have a better suggestion let me know. There are undocumented functions but they make it to the help as soon as they have proven to work. A recent one was the eeprom quick mode for xmega. _________________ Mark |
|
Back to top |
|
|
|