This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

About AgsiSetSFRValue(DWORD dwValue)

hello,
I am engaged in developing a new SPeriDLL.dll(dialog) and I can't understand the following function and its specification:

BOOL About AgsiSetSFRValue(DWORD dwValue);

"This function is used to let the SFR read value C used to watch function with read access set for the SFR
Input Parameter
dwValue SFRReadValue;
return value:True if successful(otherwise FALSE)
EXAMPLE:
static void (void
{...
AgsiSetSFRValue(P1&PORT1);
...
}
"
I can't correctly understand the above explanation.can anybody give me more words?

thanks and best regards
huihl@163.com


  • I don't see a function by exactly that name in the copy I have of app note 154. Perhaps you have an older version?

    There is one that seems to be what you're talking about, though: AgsiSetSFRReadValue(). It has a similar example, using port 0 instead of port 1.

    The purpose of this function seems to be to override the value that would be read from an SFR. Many SFRs aren't simply passive memory registers. The bits will change depending on the state of the system. So, you need a function that supplies the value that would be read from an SFR, no matter what bits are actually in that register.

    The example given is for an I/O port. To read inputs of an I/O port, you must write 1s to the port, and then read back a value. The SFR itself will contain all ones, but the read needs to return the value that's actually on the port pins. This function allows you to do exactly that. As shown in the example in the app note, you install a hook on attempts to read the I/O port, and that hook calls this function to set the actual value that should be read, based on the state of your simulated system.


  • you are right.I have gotten the newer version of note.pdf.
    when that function are called,the regiser P1 are not changed.But in the actual system,P1 would be changed on the PINS.
    since P1 were not changed,can the next read operation be exactly finished without setting the P1?

    thanks and best regards
    huihl@netease.com

  • before reading input pins of P0 in target firmware,
    you need:
    1. call AgsiDefineVTR("PORT0") to get PORT0 handle on init.
    2. call AgsiWriteVTR(PORT0) to set PIN value

    Please note that VTR PORT0 (PIN value) is masked by SFR P0. You probably need to set SFR P0 to 0xff (all pins can be used for input) before reading input PORT0 PINs.
    For example, if current value of SFR P0 is 0x01 and your AGSI DLL call AgsiWriteVTR(PORT0, 0xff), debugger will show an error message.

  • I have this problem also, but I still can't understand. The example in app note shows
    AgsiSetSFRReadValue(P0 & PORT0); // P0 (Port0 SFR Value), PORT0 (Port0 pins)

    P0 is defined as 0x80 and PORT0 is VTR handle according to Jones Salivic's message. I can't understand how they can be logically or together. Could anybody explain more about this function ?

    Thanks and regards.

  • I don't understand either. Why are they ANDing the Port register address (0x80) with the port pins? How does that affect the return value? If I wanted to set pin 7, that would be the MSB of the value, which is 0x80, the port number... so how would the pin get set or cleared? Who wrote this function and what were they thinking? Why doesn't it take a register address and value?

    I'm really annoyed at this function because it *doesn't work*! I've tried calling it with 0xff, 0x00, and every combination in between, and the code always reads the SFR value....