Hello. I need some help. I'm trying to write, read and erase an external EEPROM (25AA040 MICROCHIP) via SPI from XC164CS board, for example, one byte at 0x00 adress of the eeprom, but i don't know how to do it. Into the datasheet, I can see some instructions but i don't know what to do with them: img28.imagevenue.com/img.php Could anyone help me? Thank you very much. :)
I never worked with SPI but rather with I2C, so I don't know for sure. I think that your datasheet might tell you what you need to place on the data bus and what you need to place on the address bus in order to communicate with your device. A simple assignment into a memory mapped region will get the job done.
Perhaps you would like to look at the application note on the Infineon web site...
Interfacing the XC16x Microcontroller to a Serial SPI EEPROM -description (ap1609510_XC16x_SPI_EEPROM.pdf)
There is a pdf with code.
www.infineon.com/.../channel.html
Hello Chris, I have seen your program in the website of Infineon, and its compiler is Tasking and mine is Keil uVision. Do you have the same proyect but for my compiler? Thanks
Pfff, i'm so desperated. This program is very difficult to understand... I have been so long trying to undestand it. Is there any simple program that might help me? Thanks
Hi
I am not sure what are the difficulties but I modified some code I made previously to Keil. I then tested it on an XC164CS starterkit without issue. If you want to post your email then I will send it to you. However I am not sure if it is easier to understand though...
The program is in a few files which are to many to post here but listed below is from the main file if this is interesting to you.
const S8 txBuf[] = "Welcome to XC164CS Serial EEPROM reading/writing"; const U16 txSize = (sizeof(txBuf) - 1); S8 rxBuf[64]; /**/ void main (void) { U16 address = 0; /* EEPROM address for string */ SSC0_Init(); /* initialize the SSC peripheral */ PSW_IEN = 1; /* globally enable interrupts */ /* write bytes to the EEPROM */ EepromWriteEnable(); while(EepromBusy()); /* max page size if 64 bytes in a write */ EepromWrite(address, (U8*) &txBuf[0], (U16) txSize); while(EepromBusy()); /* wait for WRITE command to complete */ while((EepromReadStatus() & RDY_) == true); /* read back the bytes we wrote to the EEPROM */ EepromRead(address, &rxBuf[0], (U16) txSize); while(1){ _nop_(); /* loop forever */ } }
Hi Chris, my email is iker@leako.com. Send me please the program that you have and I will create a simple project in uVision with it. I only want to understand EepromWriteEnable, EepromWrite, and EepromRead functions. Thank you very much Crhis. You are teaching me a lot. ;-)
Hi John,
The Keil project was sent to your email address.
-Chris
Thanks Chris. You are GOD!. Inmediately IÂ'm going to study the proyect and attempt to understand it. I will comment you the results. Give me some time :)
Hi Chris, I have 3 questions about the project:
First one: I suppose the program writes and reads this array: txBuf[] = "Welcome to XC164CS Serial EEPROM reading/writing" into EEPROM. Isn't it? How can I check if this program writes and reads correctly?
Second one: How does the "EepromStartTx" function work? It doesnÂ't have any "for" loop to send each byte of txBuf[] to SSC0_TB?
Third one:Is SSC0 interrupt system similar to ASC0? Thanks. I go on studying.
Other question: Is there any time to comply with this?
void SSC0_viTx(void) interrupt SSC0TINT ... if ((eeprom.cmd == WRITE) && (eeprom.bytesTx == START_TX_MSG)) ...
eeprom.bytesTx is going to take as maximum, 2, isn't it?
Is there any time to comply with this?
Not sure what you mean? The transmit interrupt is working on a pointer from the serial EEPROM driver that changes depending on what count it is on and what mode (read or write).
The driver is sending the command and address which is not it the data string you are passing. The transmit interrupt routine could be made simpler if you want to include the command and address in your data. It depends on what is more important to you, abstraction of your data from the driver or not.
View all questions in Keil forum