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

SPI Simulation

I am trying to simulate an SPI device AT25128 eeprom, there is an example on the keil site which i have tried but i cant seem to get it working. Has anyone done any SPI or even I2C simulation that could help or point to some usefull sites?

Cheers.

  • Here is a very simple example. When running simulation you need to find the corresponding "simulator VTREG" that are available.

    So an example for the SSC0, configured in master mode. If you want to receive data (since you need to emulate the slave device) then you would write to the VTREG register ssc0in.

    In the command window write...
    ssc0in=0x1234

    Now when your software writes to the SSC0_TB register and the receive is finished you will see the value of 0x1234 in the RB register of the Peripheral window.

    Does this help?

  • Hi, thanks to anyone who previously replied to my SPI sim query. I am now having a problem simulating talking to an I2C device PCF8575, my main program works corrrectly with hardware so i know its doing the right thing but if i debug in sim mode and watch writes to IICOUT (vtreg) i keep getting 0x7F01 which im not sure of. 0xFFF=STOP, 0x0100=START, 0xFF00=ACK, 0xFF01=NACK, but why do i see 0x7F01 appear, sometimes twice.
    Does or has anyone seen 0x7F01 when I2C simulating?

  • Values 0x7F01 (CLK1) and 0x7F00 (CLK0) are used to simulate Clock stretching.

    Those values can be ignored when watching the IICOUT for normal operation.

  • Thanks, i still have a problem where in simulation mode im trying to sim a read from the I2C device. I get the Start Cond, then Addr, i Ack, then send 1st byte, wait for Ack, but then before i can send or even if i do i get the Stop cond.

    It all works pefectly on hardware, ive watched it on the scope and stepped through on the debugger, all is ok.

    Only when i simulate im cut short from the master receiving my 2nd byte.

    The original core code was done by DaVE and as i say worls on hardware. The device im trying to sim is PCF8575, standard stuff really.

    Although i didnt know what the 0x7F01 was i just ignored it anyway to try to get thing working.

    Can you help anymore ?

  • It seems like a simulator problem. You should send the test project with instructions how to duplicate the problem to support.intl@keil.com