In SX Microcontrollers, SX/B Compiler and SX-Key Tool, dkemppai wrote:
[quote="pjv"]
Guenther;
You are absolutely correct in your assessment.
It also behooves one to realize that on RESET of an SX48/52, that same 5th bit is NOT AFFECTED. So after a reset (not the same as a POWER-UP), the 5th bit may be set, or reset, depending of the previous state.
For greater certainty then, one should only modify the MODE register in an SX48/52 by transferring the content of W through a mov m,w instruction.
Cheers,
Peter (pjv)[/quote]
Yes, true, but under a certain situation, something weird can happen.
The SX52 data sheet says that M=$0F is only used to READ the port direction registers, and that $1F is used only for WRITES to the direction registers. Refer to the table in the SX52 datasheet (pg 12???).
Let me clear something up. IN ALL CASES, the M register was = $0F.
Again, with "mov m,#$0F" the direction registers WILL change. ([b]debugged M = $0F[/b])
The dirs WILL NOT change with "mov w,#0F" followed by "mov M,w".([b]debugged M = $0F[/b])
The gotcha here isn't the number of bits, it's the $0F value.
On the SX52 M is supposed to equal $1F to write changes to the direction registers,
but if bit 5 = 0, and you move literal to M, the direction registers will accept changes.
Whereas if you move m,w with $0f in w it will not work.
This is subtle. The gotcha here is that if you port code from an SX28 to a SX52, you may
have a very difficult bug to find (this is how I discovered it)
I debugged this several times. You can write direction registers with m = $0f, and you're not
supposed to be able to do so!
-Dan
P.S. Why does this freaking window double space at random! This double spaced thing is really starting to P!$$ me off!
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=91663#m92224
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)