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

problem in spi driver

i am working with energy metering chipade7758 and cygnal 8051f120.communication between cygnal and 8051f120 take place through SPI bus. the driver is working fine only if we initialize the SPI just before writing a byte . that means i have to reload the SPI configuration registers .
SPIEN = 0;
SPI0CFG = 0x60;
SPI0CN = 0x0C;
SPI0CKR = 0x17;
SPIEN = 1;
why this happens? I want to save the time of reloading . suggestion are most welcome …

Parents Reply Children
  • hi,

    Do you load SFRPAGE register with #SPI0_PAGE value before write to/read from SPI0DAT register?
    Seems like SPI initialization contains this line and so code works correct. But simple access to SPI0DAT (and other SPI registers) when SFRPAGE is not set to SPI one, does fail.

    Regards,
    Oleg

  • re SFRPAGE

    we all (with a few exceptions?) have problems with that one. for that reason I have developed a replacement f12x.h file where e.g TCON is renamed S0_TCON. This does not prevent mistakes, but it makes them a whole lot easier to spot.

    If anyone want a copy, e-mail me at erikm@digrec.com and make the subject line meaningful or the e-mail will not be read.

    Erik