Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Mcucsr: 2.0.8.6 - Does not work, 2.0.8.5 - ALL OK
Goto page Previous  1, 2
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Alexander-Dan

Bascom Member



Joined: 13 Mar 2014
Posts: 111
Location: S.Posad

russia.gif
PostPosted: Thu Feb 22, 2024 2:14 pm    Post subject: Reply with quote

Yes, I read about all the changes...

But since 2009 I have had a rule: no “magic” -- no assembler commands in programs!
Sometimes you need to transfer code to different chips, so assembler is very undesirable and is fraught with many problems Twisted Evil
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Thu Feb 22, 2024 2:48 pm    Post subject: Reply with quote

Alexander-Dan wrote:
But since 2009 I have had a rule: no “magic” -- no assembler commands in programs!
Sometimes you need to transfer code to different chips, so assembler is very undesirable and is fraught with many problems Twisted Evil

This is up to you, but tell me, where's do you see any assembler code? Very Happy
Code:
Dim Begunok As Byte
  Begunok = GetReg(R0)
  Begunok = R0 ' since ver. 2.0.7.8

See the help --> GetReg()
For explanation of R0, help --> Config Watchdog

Both MCUCSR and R0 are processor registers with no difference to read them.
The more the Bascom compiler supports reading the reset-cause by R0 over differnt platforms like ATTiny, ATMega, XMega, you will be better off with this method.
Back to top
View user's profile
Alexander-Dan

Bascom Member



Joined: 13 Mar 2014
Posts: 111
Location: S.Posad

russia.gif
PostPosted: Thu Feb 22, 2024 3:50 pm    Post subject: Reply with quote

"magic" is what is not visible in the code Cool

If I read a chip register MCUCSR, then I can find a description of that register in the chip's datasheets.
If I write "R0", then I don’t know what the compiler does inside and I have to look in third-party sources for the compiler itself and all its versions!

At the same time, I cannot be sure that tomorrow, in the new version of the compiler, these “old tricks” will not be replaced by new “progressive things”. ha-ha
I don't argue and I don't encourage you to do the same. Each of us has our own personal experience and coding style...
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Thu Feb 22, 2024 6:26 pm    Post subject: Reply with quote

Alexander-Dan wrote:
I cannot be sure that tomorrow, in the new version of the compiler, these “old tricks” will not be replaced by new “progressive things”.

No, you can't be sure.
But as you use this compiler you seem to feel it is trustworthy.
Would you not believe it to be trustworthy, you need to go bare-metal and use assembler code. But still then, a new assembler may do things different.

Any type of compiler may change it's behavior over time, and any maker of any compiler will try not to alienate its users by doing things completely different.

But, this is not the case here.
Backing up MCUCSR into R0 is likely older than the time you use this compiler.
You simply ignored it, because you thought there's no need to care.

What can you do now, as it has changed and you still don't like to read R0?
You can use older versions, for example 2.0.8.5
You can try to patch the *.dat file accordingly, look for WD=MCUCSR.WDRF,$E0 as described in history.txt
You can patch the created *.hex
You can NOT misuse $INITMICRO, as access of MCUCSR happens earlier.
You can throw yourself on the floor and start crying.
Will it help? Laughing

PS:
Alexander-Dan wrote:
If I write "R0", then I don’t know what the compiler does inside

I can tell you: Nothing will happen, as R0 is only a copy of MCUCSR.
After the copy was done, all flags in MCUCSR are cleared, but you'll find them as copy in R0.

With a MCUSR (..status register only) read access is sufficient, in contrary with MCUCSR (..control and status register), as there may be bits you want to write.
Of course you write them into MCUCSR then and not its copy R0.
Back to top
View user's profile
Alexander-Dan

Bascom Member



Joined: 13 Mar 2014
Posts: 111
Location: S.Posad

russia.gif
PostPosted: Thu Feb 22, 2024 7:21 pm    Post subject: Reply with quote

oh so many words.
I looked at the calendar: no, today is not Friday and tomorrow is not Saturday. Too many emotions in a working day Very Happy
I can indulge myself: I’m on vacation.

But I will answer briefly: thank you
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Thu Feb 22, 2024 8:40 pm    Post subject: Reply with quote

Alexander-Dan wrote:
But I will answer briefly: thank you

Relax Wink No emotions were involved, neither hurt.
Words come out of my keyboard easily, I have even to delete some. Laughing
You're welcome of course.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum