BTW, you can't immediately de-assert CS after calling SSP0Send because you
don't know whether the hardware has shifted all bits written to DR onto the
SPI bus
Just saying.
--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore Development Platform http://www.soldercore.com
LPC1764 SPI assistance with 25LC512 EEPROM
Started by ●August 17, 2013
Reply by ●August 27, 20132013-08-27
Reply by ●August 28, 20132013-08-28
Good point Paul. I normally use the send/receive function, even if I'm only
sending. I added the other functions for thoroughness, but apparently
didn't test thoroughly.
Jeff
Jeff
Reply by ●August 28, 20132013-08-28
I looked at the send receive function and it looks like a lot of the status
checking is done within the SSP read write function that I am given.
Here is the send function I am given:
________________________________________
Here is the receive function I am given:
________________________________________
And here is the read write function I am given. I'm not sure how to use this function, which is why I tried using the more simpler read and write functions.
How would I modify the send receive function and use what is in the "ReadWrite" function? Also, SSP0DR and SSP0SR come up as undefined, so I'm guessing I should still sue what is in the send and recieve function as a basis in the above functions.
Here is the send function I am given:
________________________________________
Here is the receive function I am given:
________________________________________
And here is the read write function I am given. I'm not sure how to use this function, which is why I tried using the more simpler read and write functions.
How would I modify the send receive function and use what is in the "ReadWrite" function? Also, SSP0DR and SSP0SR come up as undefined, so I'm guessing I should still sue what is in the send and recieve function as a basis in the above functions.
Reply by ●September 10, 20132013-09-10
Reply by ●September 11, 20132013-09-11
The SSP has a FIFO and each frame sent results in a frame received. So in your
readEEPROM function, you send the read command, the address, and then read data.
The read data will read the frame in the FIFO that corresponds to the read
command.
Also, what is your frame size? If 8 bits, then the address must be broken into high and low bytes sent in two frames.
Jeff
Also, what is your frame size? If 8 bits, then the address must be broken into high and low bytes sent in two frames.
Jeff
Reply by ●September 11, 20132013-09-11
I see the following in theSSP_ConfigStructInit function:
SSP_InitStruct->CPHA = SSP_CPHA_FIRST;
SSP_InitStruct->CPOL = SSP_CPOL_HI;
SSP_InitStruct->ClockRate = 10000000;
SSP_InitStruct->Databit = SSP_DATABIT_8;
SSP_InitStruct->Mode = SSP_MASTER_MODE;
SSP_InitStruct->FrameFormat = SSP_FRAME_SPI;
So, the frame size is 8 bits. I had the address broken up before and it still didn't work. I'll put it back as it was before:
unsigned char addressHighByte = (address>>8)&0x00FF;
unsigned char addressLowByte = (address&0x00FF);
...
SSPSend(SSP_CHANNEL,addressHighByte); // byte 1 16bit address to read
SSPSend(SSP_CHANNEL,addressLowByte);
SSP_InitStruct->CPHA = SSP_CPHA_FIRST;
SSP_InitStruct->CPOL = SSP_CPOL_HI;
SSP_InitStruct->ClockRate = 10000000;
SSP_InitStruct->Databit = SSP_DATABIT_8;
SSP_InitStruct->Mode = SSP_MASTER_MODE;
SSP_InitStruct->FrameFormat = SSP_FRAME_SPI;
So, the frame size is 8 bits. I had the address broken up before and it still didn't work. I'll put it back as it was before:
unsigned char addressHighByte = (address>>8)&0x00FF;
unsigned char addressLowByte = (address&0x00FF);
...
SSPSend(SSP_CHANNEL,addressHighByte); // byte 1 16bit address to read
SSPSend(SSP_CHANNEL,addressLowByte);
Reply by ●September 12, 20132013-09-12
Refer to my earlier post regarding the FIFO in the SSP. You will either have to
follow every write with a read or use the send/recieve fuction that I posted a
while back.
Your code will not keep the Rx and Tx FIFO's synchronized.
Jeff
Your code will not keep the Rx and Tx FIFO's synchronized.
Jeff
Reply by ●September 12, 20132013-09-12
GOT IT! I tested two memory locations and both now make the LED blink. Thanks to
ksdoubleshooter and the rest as well as thisan accelerometer example:
http://keadrone.googlecode.com/svn-history/r72/trunk/firmware/Keadrone/src/dAccelerometer_BMA180.c
I realized how the given SSP example works. Here are the working functions:
I have to check which delays are required, but it works. If anyone wants to play around with it and test it out as well you are more than welcome.
I still have one more question if no one minds. Can the SSP module run at 50MHz if I adjust the prescaler configuration? Right now it is divide by 4, so that is 25MHz (100MHz/4). So, if I change it to two it should work? The reason is I am going to replace the EEPROM with a Flash chip in the near future and it operates at 50MHz SPI.
http://keadrone.googlecode.com/svn-history/r72/trunk/firmware/Keadrone/src/dAccelerometer_BMA180.c
I realized how the given SSP example works. Here are the working functions:
I have to check which delays are required, but it works. If anyone wants to play around with it and test it out as well you are more than welcome.
I still have one more question if no one minds. Can the SSP module run at 50MHz if I adjust the prescaler configuration? Right now it is divide by 4, so that is 25MHz (100MHz/4). So, if I change it to two it should work? The reason is I am going to replace the EEPROM with a Flash chip in the near future and it operates at 50MHz SPI.