Reply by nfor...@gmail.com 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.

An Engineer's Guide to the LPC2100 Series

Reply by ksdoubleshooter 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

Reply by nfor...@gmail.com 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);
Reply by ksdoubleshooter 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

Reply by nfor...@gmail.com September 10, 20132013-09-10
Reply by Nick 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.
Reply by ksdoubleshooter 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
Reply by Paul Curtis August 27, 20132013-08-27
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
Reply by Nick August 27, 20132013-08-27
Thank you so much guys! You are exactly right the delays actually only worked for sending and receiving 1 byte, when I recently tried multiple bytes and it doesn't work. The reason may just be the status bit that ksdoubleshooter kindly pointed out. I'll give it ago and post back if it works, maybe I don't need any delays at all, but I'll try it with both.

Additionally, I did create a ns and microsecond delay functions I can also test as well, but I'll try the ms delay with the system tick first.
Reply by Paul Curtis August 23, 20132013-08-23
Hi,

> Hi Nick,
>
>
>
> It seems to me that the 100ns from the datasheet is the minimum time delay
> needed for it to work. Anything above that will make it work just fine.
> 1ms is good enough, it is not worth the trouble to create a 100ns delay.
>
> Your code seems wrong though, where one reads:
>
> else
>
> {
> systick_delay(1); // wait 1ms
> PORT_CS->FIOCLR |= PIN_MASK_CS; //CS low

...actually, I believe you would require

PORT_CS->FIOCLR = PIN_MASK_CS; //CS low

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
SolderCore Development Platform http://www.soldercore.com