<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: LPC1764 Using SSP1 for EEPROM SPI communication at 10MHz help in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1764-Using-SSP1-for-EEPROM-SPI-communication-at-10MHz-help/m-p/521723#M4359</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by wmues on Mon Aug 26 08:34:37 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The positions of the delay() in your source code makes no sense for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only place in the code a delay() makes sense is after CD low.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using SPI to serial nand flash @20Mhz clock, and I don't have to use any delay for CS low/high.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(I am using bit banding for CS handling, doing the read-modify-write in hardware).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: the *best* way to do small amount of delay is to read an IO register.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wolfgang&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:52:28 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:52:28Z</dc:date>
    <item>
      <title>LPC1764 Using SSP1 for EEPROM SPI communication at 10MHz help</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1764-Using-SSP1-for-EEPROM-SPI-communication-at-10MHz-help/m-p/521721#M4357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by micro9000 on Sun Aug 18 16:32:08 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hey guys, I could use some help. I am using LPCexpresso 5.2.6, LPC-Link 2, and an LPC1764 microcontroller. The problem is I cannot get my LED to blink when I am reading a value that should be in address 0 (if what I am doing is correct) of the EEPROM. I am attempting to do this using SSP1 working as SPI at 10MHz. Here is the code I am using:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;/*
===============================================================================
 Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : main.c
 Author&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 
 Version&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :
 Copyright&amp;nbsp;&amp;nbsp; : Copyright (C) 
 Description : main definition
===============================================================================
*/

#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif

#include &amp;lt;cr_section_macros.h&amp;gt;
#include &amp;lt;NXP/crp.h&amp;gt;

#include "leds.h"
#include "timer.h"
#include "Systemtick_Delay.h"

#include "lpc17xx_ssp.h" // added for eeprom

//Defines for spi
#define SSP_CHANNEL LPC_SSP1
#define PORT_CSLPC_GPIO2
#define PIN_MASK_CS (1&amp;lt;&amp;lt;2)

//Define instructions of 25LC512 EEPROM
#define WREN&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x06&amp;nbsp;&amp;nbsp;&amp;nbsp; // write enable
#define WRDI&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x04&amp;nbsp;&amp;nbsp;&amp;nbsp; // write disable
#define WRITE&amp;nbsp;&amp;nbsp; 0x02&amp;nbsp;&amp;nbsp;&amp;nbsp; // initialize start of write sequence
#define READ&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x03&amp;nbsp;&amp;nbsp;&amp;nbsp; // initialize start of read sequence
#define CE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0xc7&amp;nbsp;&amp;nbsp;&amp;nbsp; // erase all sectors of memory
#define RDSR&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x05&amp;nbsp;&amp;nbsp;&amp;nbsp; // read STATUS register


// NOTE: #define PLL0CFG_Val 0x00090063 ensure this is the case in CMISvp00_17xx under system_LPCxx.c
//&amp;nbsp; see user manual section 4.5 for more information

int main(void) {

led2_init();// Setup GPIO for LED2
led2_on();
SysTick_Init();

unsigned char readSPIvalue=0;

//Initialize timer
//init_timer( 0, TIMER0_INTERVAL );
//enable_timer( 0 );

//eeprom spi set up
SSP_CFG_Type sspChannelConfig;

// see pg 108/840 in datasheet, Pin Function Select register 0
LPC_PINCON-&amp;gt;PINSEL0 |= 0x2&amp;lt;&amp;lt;14; //SCK1
LPC_PINCON-&amp;gt;PINSEL0 |= 0x2&amp;lt;&amp;lt;18;//MOSI1
LPC_PINCON-&amp;gt;PINSEL0 |= 0x2&amp;lt;&amp;lt;16;//MISO1

PORT_CS-&amp;gt;FIODIR |= 1&amp;lt;&amp;lt;2;//P2.2 as CSn


SSP_ConfigStructInit(&amp;amp;sspChannelConfig);
SSP_Init(SSP_CHANNEL, &amp;amp;sspChannelConfig);
SSP_Cmd(SSP_CHANNEL, ENABLE);



// config EEPROM to enable writing
PORT_CS-&amp;gt;FIOCLR |= PIN_MASK_CS;//CS low
SSP_SendData(SSP_CHANNEL,WREN); // write enable command
PORT_CS-&amp;gt;FIOSET |= PIN_MASK_CS; //CS High


PORT_CS-&amp;gt;FIOCLR |= PIN_MASK_CS;//CS low
SSP_SendData(SSP_CHANNEL,WRITE);// write command
SSP_SendData(SSP_CHANNEL,0x00); // write address
SSP_SendData(SSP_CHANNEL,0x00); // write address
SSP_SendData(SSP_CHANNEL,100); // Data to send
PORT_CS-&amp;gt;FIOSET |= PIN_MASK_CS; //CS High


//------------------------ Main Loop---------------------------
while(1) {


if(readSPIvalue==100) // initially it is 0
{
//make LED blink if eeprom read
led2_invert();// Toggle state of LED2
}
else
{
//checkEEPROM_Busy();
PORT_CS-&amp;gt;FIOCLR |= PIN_MASK_CS;//CS low
SSP_SendData(SSP_CHANNEL,READ); // read command
SSP_SendData(SSP_CHANNEL,0x00); // byte 1 16bit address to read
SSP_SendData(SSP_CHANNEL,0x00); // byte 2 16bit address to read

SSP_SendData(SSP_CHANNEL,0x00); // clock data out for reading
readSPIvalue=SSP_ReceiveData(SSP_CHANNEL);
PORT_CS-&amp;gt;FIOSET |= PIN_MASK_CS; //CS High
}

systick_delay(200); // wait 2 seconds (2000ms)
//led2_invert();// Toggle state of LED2
}


return 0 ;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NOTE: This is based off of the ssp_spi example provided. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, here are the connections I am using:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://http://s188.photobucket.com/user/fac7orx/media/eepromARMpic_zpsdc524e83.png.html" rel="nofollow noopener noreferrer" target="_blank"&gt;[IMG]http://i188.photobucket.com/albums/z265/fac7orx/eepromARMpic_zpsdc524e83.png[/IMG]&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And here is the datasheet for the EEPROM:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fww1.microchip.com%2Fdownloads%2Fen%2Fdevicedoc%2F22065a.pdf" rel="nofollow noopener noreferrer" target="_blank"&gt;http://ww1.microchip.com/downloads/en/devicedoc/22065a.pdf&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In addition, I have set the clock rate in the function SSP_ConfigStructInit:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;void SSP_ConfigStructInit(SSP_CFG_Type *SSP_InitStruct)
{
SSP_InitStruct-&amp;gt;CPHA = SSP_CPHA_FIRST;
SSP_InitStruct-&amp;gt;CPOL = SSP_CPOL_HI;
SSP_InitStruct-&amp;gt;ClockRate = 1000000;
SSP_InitStruct-&amp;gt;Databit = SSP_DATABIT_8;
SSP_InitStruct-&amp;gt;Mode = SSP_MASTER_MODE;
SSP_InitStruct-&amp;gt;FrameFormat = SSP_FRAME_SPI;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, judging from the code I have posted above is something missing? I have included the necessary files such as lpc_17xx_clkpwr.c and .h, lpc17xx_ssp.c and .h, as well as lpc17xx_libcfg_Default.c.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:52:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1764-Using-SSP1-for-EEPROM-SPI-communication-at-10MHz-help/m-p/521721#M4357</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1764 Using SSP1 for EEPROM SPI communication at 10MHz help</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1764-Using-SSP1-for-EEPROM-SPI-communication-at-10MHz-help/m-p/521722#M4358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by micro9000 on Thu Aug 22 14:53:41 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I managed to figure it out. I needed a delay after and before the /CS pin was asserted low and high. Here is what the read statement look like within the main while loop now:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;systick_delay(1); // wait 1ms&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PORT_CS-&amp;gt;FIOCLR |= PIN_MASK_CS;//CS low&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SSP_SendData(SSP_CHANNEL,READ); // read command&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SSP_SendData(SSP_CHANNEL,0x00); // byte 1 16bit address to read&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SSP_SendData(SSP_CHANNEL,0x00); // byte 2 16bit address to read&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SSP_SendData(SSP_CHANNEL,0x00); // clock data out for reading&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;readSPIvalue=SSP_ReceiveData(SSP_CHANNEL);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;systick_delay(1); // 1ms&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PORT_CS-&amp;gt;FIOSET |= PIN_MASK_CS; //CS High&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have to find out how to use timers as delays, for milliseconds using system tick isn't going to cut it. From the datasheet, the delay has to be about 100ns, but it still works with 1ms. I think I can use the match register to do this I just have to configure the PCLK to be system clock divided by 2 instead of 4.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:52:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1764-Using-SSP1-for-EEPROM-SPI-communication-at-10MHz-help/m-p/521722#M4358</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1764 Using SSP1 for EEPROM SPI communication at 10MHz help</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1764-Using-SSP1-for-EEPROM-SPI-communication-at-10MHz-help/m-p/521723#M4359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by wmues on Mon Aug 26 08:34:37 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The positions of the delay() in your source code makes no sense for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only place in the code a delay() makes sense is after CD low.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using SPI to serial nand flash @20Mhz clock, and I don't have to use any delay for CS low/high.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(I am using bit banding for CS handling, doing the read-modify-write in hardware).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: the *best* way to do small amount of delay is to read an IO register.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wolfgang&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:52:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1764-Using-SSP1-for-EEPROM-SPI-communication-at-10MHz-help/m-p/521723#M4359</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1764 Using SSP1 for EEPROM SPI communication at 10MHz help</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1764-Using-SSP1-for-EEPROM-SPI-communication-at-10MHz-help/m-p/521724#M4360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by capiman on Mon Aug 26 08:46:02 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The same question and already some (same) answers here in lpc2000 yahoo mailing list:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Ftech.groups.yahoo.com%2Fgroup%2Flpc2000%2Fmessage%2F58980" rel="nofollow" target="_blank"&gt;http://tech.groups.yahoo.com/group/lpc2000/message/58980&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:52:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1764-Using-SSP1-for-EEPROM-SPI-communication-at-10MHz-help/m-p/521724#M4360</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:52:29Z</dc:date>
    </item>
  </channel>
</rss>

