<?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>LPC MicrocontrollersのトピックCan't get SPI1 to work on LPC1517</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Can-t-get-SPI1-to-work-on-LPC1517/m-p/712253#M28753</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using the LPC1517 with LPCXpresso 8.2.2 based on the peripheral_spi_polling project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The example is on SPI0 and with the loopback turned off I can see the clock and SSEL&amp;nbsp;working correctly on the logic analyser.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I change the code to SPI1 I can only see the clock, the SSEL&amp;nbsp;line is not going low.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something else I need to do to get SPI1 working ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define CLK 17&lt;BR /&gt;#define SSEL 27&lt;BR /&gt;#define MISO 28&lt;BR /&gt;#define MOSI 13&lt;/P&gt;&lt;P&gt;static void Init_SPI_PinMux(void)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;/* Enable the clock to the Switch Matrix */&lt;BR /&gt; Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);&lt;/P&gt;&lt;P&gt;Chip_IOCON_PinMuxSet(LPC_IOCON, 0, CLK, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));&lt;BR /&gt; Chip_IOCON_PinMuxSet(LPC_IOCON, 0, SSEL, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));&lt;BR /&gt; Chip_IOCON_PinMuxSet(LPC_IOCON, 0, MISO, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));&lt;BR /&gt; Chip_IOCON_PinMuxSet(LPC_IOCON, 0, MOSI, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));&lt;/P&gt;&lt;P&gt;Chip_SWM_MovablePinAssign(SWM_SPI1_SCK_IO, CLK); /* P0.0 */&lt;BR /&gt; Chip_SWM_MovablePinAssign(SWM_SPI1_MOSI_IO, MOSI);/* P0.16 */&lt;BR /&gt; Chip_SWM_MovablePinAssign(SWM_SPI1_MISO_IO, MISO);/* P0.10 */&lt;BR /&gt; Chip_SWM_MovablePinAssign(SWM_SPI1_SSELSN_0_IO, SSEL); /* P0.9 */&lt;/P&gt;&lt;P&gt;/* Disable the clock to the Switch Matrix to save power */&lt;BR /&gt; Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/* Turn on LED to indicate an error */&lt;BR /&gt;static void errorSPI(void)&lt;BR /&gt;{&lt;BR /&gt; Board_LED_Set(0, true);&lt;BR /&gt; while (1) {}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* Setup SPI handle and parameters */&lt;BR /&gt;static void setupSpiMaster()&lt;BR /&gt;{&lt;BR /&gt; SPI_CFG_T spiCfg;&lt;BR /&gt; SPI_DELAY_CONFIG_T spiDelayCfg;&lt;BR /&gt; /* Initialize SPI Block */&lt;BR /&gt; Chip_SPI_Init(LPC_SPI1);&lt;BR /&gt; /* Set SPI Config register */&lt;BR /&gt; spiCfg.ClkDiv = 0xFFFF; /* Set Clock divider to maximum */&lt;BR /&gt; spiCfg.Mode = SPI_MODE_MASTER; /* Enable Master Mode */&lt;BR /&gt; spiCfg.ClockMode = SPI_CLOCK_MODE0; /* Enable Mode 0 */&lt;BR /&gt; spiCfg.DataOrder = SPI_DATA_MSB_FIRST; /* Transmit MSB first */&lt;BR /&gt; /* Slave select polarity is active low */&lt;BR /&gt; spiCfg.SSELPol = (SPI_CFG_SPOL0_LO | SPI_CFG_SPOL1_LO | SPI_CFG_SPOL2_LO | SPI_CFG_SPOL3_LO);&lt;BR /&gt; Chip_SPI_SetConfig(LPC_SPI1, &amp;amp;spiCfg);&lt;BR /&gt; /* Set Delay register */&lt;BR /&gt; spiDelayCfg.PreDelay = 2;&lt;BR /&gt; spiDelayCfg.PostDelay = 2;&lt;BR /&gt; spiDelayCfg.FrameDelay = 2;&lt;BR /&gt; spiDelayCfg.TransferDelay = 2;&lt;BR /&gt; Chip_SPI_DelayConfig(LPC_SPI1, &amp;amp;spiDelayCfg);&lt;BR /&gt; /* Enable Loopback mode for this example */&lt;BR /&gt; //Chip_SPI_EnableLoopBack(LPC_SPI0);&lt;BR /&gt; /* Enable SPI0 */&lt;BR /&gt; Chip_SPI_Enable(LPC_SPI1);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* Master SPI transmit in polling mode */&lt;BR /&gt;static void WriteSpiMssg(uint16_t *xferPtr, uint32_t xferSize)&lt;BR /&gt;{&lt;BR /&gt; uint8_t i;&lt;BR /&gt; /* Setup Transfer structure, this data should be retained for the entire transmission */&lt;BR /&gt; XferSetup.pTx = xferArray; /* Transmit Buffer */&lt;BR /&gt; XferSetup.pRx = rx_buff;/* Receive Buffer */&lt;BR /&gt; XferSetup.DataSize = sizeof(xferArray[0]) * 8; /* Data size in bits */&lt;BR /&gt; XferSetup.Length = sizeof(xferArray) / sizeof(xferArray[0]); /* Total frame length */&lt;/P&gt;&lt;P&gt;/* Assert only SSEL0 */&lt;BR /&gt; ///XferSetup.ssel = SPI_TXCTL_ASSERT_SSEL0 | SPI_TXCTL_DEASSERT_SSEL1;// | SPI_TXCTL_DEASSERT_SSEL2 | SPI_TXCTL_DEASSERT_SSEL3;&lt;BR /&gt; XferSetup.ssel = SPI_TXCTL_ASSERT_SSEL0 | SPI_TXCTL_DEASSERT_SSEL1;&lt;/P&gt;&lt;P&gt;XferSetup.TxCnt = 0;&lt;BR /&gt; XferSetup.RxCnt = 0;&lt;BR /&gt; /* Transfer message as SPI master via polling */&lt;BR /&gt; if (Chip_SPI_RWFrames_Blocking(LPC_SPI1, &amp;amp;XferSetup) &amp;gt; 0) {&lt;BR /&gt; /* If transmit successful then verify received data */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; /* Signal SPI error */&lt;BR /&gt; errorSPI();&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Public functions&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * @brief Main routine for SPI example&lt;BR /&gt; * @return Function should not exit&lt;BR /&gt; */&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; int i;&lt;BR /&gt; /* Generic Initialization */&lt;BR /&gt; SystemCoreClockUpdate();&lt;BR /&gt; Board_Init();&lt;/P&gt;&lt;P&gt;/* Clear activity LED */&lt;BR /&gt; Board_LED_Set(0, false);&lt;/P&gt;&lt;P&gt;/* Setup SPI pin muxing */&lt;BR /&gt; Init_SPI_PinMux();&lt;/P&gt;&lt;P&gt;/* Allocate SPI handle, setup rate, and initialize clocking */&lt;BR /&gt; setupSpiMaster();&lt;/P&gt;&lt;P&gt;/* Loop forever */&lt;BR /&gt; while (1) {&lt;BR /&gt; /* Write simple message over SPI */&lt;BR /&gt; WriteSpiMssg(xferArray, sizeof(xferArray) / sizeof(xferArray[0]));&lt;/P&gt;&lt;P&gt;for( i = 0;i &amp;lt;1000000;i++);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Code never reaches here. Only used to satisfy standard main() */&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 22 Oct 2017 13:20:18 GMT</pubDate>
    <dc:creator>sukkinpang</dc:creator>
    <dc:date>2017-10-22T13:20:18Z</dc:date>
    <item>
      <title>Can't get SPI1 to work on LPC1517</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Can-t-get-SPI1-to-work-on-LPC1517/m-p/712253#M28753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using the LPC1517 with LPCXpresso 8.2.2 based on the peripheral_spi_polling project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The example is on SPI0 and with the loopback turned off I can see the clock and SSEL&amp;nbsp;working correctly on the logic analyser.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I change the code to SPI1 I can only see the clock, the SSEL&amp;nbsp;line is not going low.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something else I need to do to get SPI1 working ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define CLK 17&lt;BR /&gt;#define SSEL 27&lt;BR /&gt;#define MISO 28&lt;BR /&gt;#define MOSI 13&lt;/P&gt;&lt;P&gt;static void Init_SPI_PinMux(void)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;/* Enable the clock to the Switch Matrix */&lt;BR /&gt; Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);&lt;/P&gt;&lt;P&gt;Chip_IOCON_PinMuxSet(LPC_IOCON, 0, CLK, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));&lt;BR /&gt; Chip_IOCON_PinMuxSet(LPC_IOCON, 0, SSEL, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));&lt;BR /&gt; Chip_IOCON_PinMuxSet(LPC_IOCON, 0, MISO, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));&lt;BR /&gt; Chip_IOCON_PinMuxSet(LPC_IOCON, 0, MOSI, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));&lt;/P&gt;&lt;P&gt;Chip_SWM_MovablePinAssign(SWM_SPI1_SCK_IO, CLK); /* P0.0 */&lt;BR /&gt; Chip_SWM_MovablePinAssign(SWM_SPI1_MOSI_IO, MOSI);/* P0.16 */&lt;BR /&gt; Chip_SWM_MovablePinAssign(SWM_SPI1_MISO_IO, MISO);/* P0.10 */&lt;BR /&gt; Chip_SWM_MovablePinAssign(SWM_SPI1_SSELSN_0_IO, SSEL); /* P0.9 */&lt;/P&gt;&lt;P&gt;/* Disable the clock to the Switch Matrix to save power */&lt;BR /&gt; Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/* Turn on LED to indicate an error */&lt;BR /&gt;static void errorSPI(void)&lt;BR /&gt;{&lt;BR /&gt; Board_LED_Set(0, true);&lt;BR /&gt; while (1) {}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* Setup SPI handle and parameters */&lt;BR /&gt;static void setupSpiMaster()&lt;BR /&gt;{&lt;BR /&gt; SPI_CFG_T spiCfg;&lt;BR /&gt; SPI_DELAY_CONFIG_T spiDelayCfg;&lt;BR /&gt; /* Initialize SPI Block */&lt;BR /&gt; Chip_SPI_Init(LPC_SPI1);&lt;BR /&gt; /* Set SPI Config register */&lt;BR /&gt; spiCfg.ClkDiv = 0xFFFF; /* Set Clock divider to maximum */&lt;BR /&gt; spiCfg.Mode = SPI_MODE_MASTER; /* Enable Master Mode */&lt;BR /&gt; spiCfg.ClockMode = SPI_CLOCK_MODE0; /* Enable Mode 0 */&lt;BR /&gt; spiCfg.DataOrder = SPI_DATA_MSB_FIRST; /* Transmit MSB first */&lt;BR /&gt; /* Slave select polarity is active low */&lt;BR /&gt; spiCfg.SSELPol = (SPI_CFG_SPOL0_LO | SPI_CFG_SPOL1_LO | SPI_CFG_SPOL2_LO | SPI_CFG_SPOL3_LO);&lt;BR /&gt; Chip_SPI_SetConfig(LPC_SPI1, &amp;amp;spiCfg);&lt;BR /&gt; /* Set Delay register */&lt;BR /&gt; spiDelayCfg.PreDelay = 2;&lt;BR /&gt; spiDelayCfg.PostDelay = 2;&lt;BR /&gt; spiDelayCfg.FrameDelay = 2;&lt;BR /&gt; spiDelayCfg.TransferDelay = 2;&lt;BR /&gt; Chip_SPI_DelayConfig(LPC_SPI1, &amp;amp;spiDelayCfg);&lt;BR /&gt; /* Enable Loopback mode for this example */&lt;BR /&gt; //Chip_SPI_EnableLoopBack(LPC_SPI0);&lt;BR /&gt; /* Enable SPI0 */&lt;BR /&gt; Chip_SPI_Enable(LPC_SPI1);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* Master SPI transmit in polling mode */&lt;BR /&gt;static void WriteSpiMssg(uint16_t *xferPtr, uint32_t xferSize)&lt;BR /&gt;{&lt;BR /&gt; uint8_t i;&lt;BR /&gt; /* Setup Transfer structure, this data should be retained for the entire transmission */&lt;BR /&gt; XferSetup.pTx = xferArray; /* Transmit Buffer */&lt;BR /&gt; XferSetup.pRx = rx_buff;/* Receive Buffer */&lt;BR /&gt; XferSetup.DataSize = sizeof(xferArray[0]) * 8; /* Data size in bits */&lt;BR /&gt; XferSetup.Length = sizeof(xferArray) / sizeof(xferArray[0]); /* Total frame length */&lt;/P&gt;&lt;P&gt;/* Assert only SSEL0 */&lt;BR /&gt; ///XferSetup.ssel = SPI_TXCTL_ASSERT_SSEL0 | SPI_TXCTL_DEASSERT_SSEL1;// | SPI_TXCTL_DEASSERT_SSEL2 | SPI_TXCTL_DEASSERT_SSEL3;&lt;BR /&gt; XferSetup.ssel = SPI_TXCTL_ASSERT_SSEL0 | SPI_TXCTL_DEASSERT_SSEL1;&lt;/P&gt;&lt;P&gt;XferSetup.TxCnt = 0;&lt;BR /&gt; XferSetup.RxCnt = 0;&lt;BR /&gt; /* Transfer message as SPI master via polling */&lt;BR /&gt; if (Chip_SPI_RWFrames_Blocking(LPC_SPI1, &amp;amp;XferSetup) &amp;gt; 0) {&lt;BR /&gt; /* If transmit successful then verify received data */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; /* Signal SPI error */&lt;BR /&gt; errorSPI();&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*****************************************************************************&lt;BR /&gt; * Public functions&lt;BR /&gt; ****************************************************************************/&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * @brief Main routine for SPI example&lt;BR /&gt; * @return Function should not exit&lt;BR /&gt; */&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; int i;&lt;BR /&gt; /* Generic Initialization */&lt;BR /&gt; SystemCoreClockUpdate();&lt;BR /&gt; Board_Init();&lt;/P&gt;&lt;P&gt;/* Clear activity LED */&lt;BR /&gt; Board_LED_Set(0, false);&lt;/P&gt;&lt;P&gt;/* Setup SPI pin muxing */&lt;BR /&gt; Init_SPI_PinMux();&lt;/P&gt;&lt;P&gt;/* Allocate SPI handle, setup rate, and initialize clocking */&lt;BR /&gt; setupSpiMaster();&lt;/P&gt;&lt;P&gt;/* Loop forever */&lt;BR /&gt; while (1) {&lt;BR /&gt; /* Write simple message over SPI */&lt;BR /&gt; WriteSpiMssg(xferArray, sizeof(xferArray) / sizeof(xferArray[0]));&lt;/P&gt;&lt;P&gt;for( i = 0;i &amp;lt;1000000;i++);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Code never reaches here. Only used to satisfy standard main() */&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Oct 2017 13:20:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Can-t-get-SPI1-to-work-on-LPC1517/m-p/712253#M28753</guid>
      <dc:creator>sukkinpang</dc:creator>
      <dc:date>2017-10-22T13:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get SPI1 to work on LPC1517</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Can-t-get-SPI1-to-work-on-LPC1517/m-p/712254#M28754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sukkin Pang,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I don't have LPC1517, so I test it on my LPC1549 with you code, based on the lpcopen peripheral_spi_polling project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I just test the SCK on P0_17 and SSEL on P0_27, the following picture is the waveform.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/1633i54E2C43ACD660E49/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can find the SSEL still have the signal. It means your software is correct.&lt;/P&gt;&lt;P&gt;So, I think you still need to check your hardware, whether you test the correct pin.&lt;/P&gt;&lt;P&gt;Wish it helps you!&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Kerry&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Oct 2017 09:26:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Can-t-get-SPI1-to-work-on-LPC1517/m-p/712254#M28754</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2017-10-24T09:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get SPI1 to work on LPC1517</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Can-t-get-SPI1-to-work-on-LPC1517/m-p/712255#M28755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Watch out for the bugs in the SPI module! If an interrupt happens whilst in use, the SSEL signals get into a mess. Much better to set and reset the SSEL signals by toggling the port bits instead of relying on the SPI module to do it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Nov 2017 09:29:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Can-t-get-SPI1-to-work-on-LPC1517/m-p/712255#M28755</guid>
      <dc:creator>ianbenton</dc:creator>
      <dc:date>2017-11-23T09:29:04Z</dc:date>
    </item>
  </channel>
</rss>

