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 …
Thanks a ton for your reply If we do not initialize it before writing a byte then I'm getting 0x0000 or 0xFFFF if i read back from the written registers. I have tried to write to a specific memory location But after reading back the same register i don't get the same value. But IT IS WORKING FINE if i do the initialization before writing. But this initialization routine is slowing down my program. Kindly revert with suitable suggestion.
1) did you copy your SPI code from a SILabs appnote? 2) if not why not? 3) if no appnote exist, use CodeArchitect, free from http://www.esacademy.com, the changes to the SILabs derivatives (NOT the f3xx deviates) are nominal. Erik
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