<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SPIM on nRF52832 and nRF52810</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85222/spim-on-nrf52832-and-nrf52810</link><description>Hi, 
 I have enabled SPIM on nRF52810 and worked normally.But when I enabled on nRF52832, it worked unusual. 
 I had defined CONFIG_NFCT_PINS_AS_GPIOS because used P0.9 and P10. Is there any other settings different between nRF52810 and nRF52832?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Mar 2022 14:13:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85222/spim-on-nrf52832-and-nrf52810" /><item><title>RE: SPIM on nRF52832 and nRF52810</title><link>https://devzone.nordicsemi.com/thread/355588?ContentTypeID=1</link><pubDate>Tue, 01 Mar 2022 14:13:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5b1af5b-b1b5-4967-b124-184176fc1e96</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I suggest to reduce the&amp;nbsp;SPI frequency&amp;nbsp;to check if that have any impact on the issue, also it might be useful to measure the pins with an analog input to check if they are logic high/low, or marginally out of spec.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM on nRF52832 and nRF52810</title><link>https://devzone.nordicsemi.com/thread/355341?ContentTypeID=1</link><pubDate>Mon, 28 Feb 2022 15:46:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea976972-7d02-493b-98f4-af2e4fa31df9</guid><dc:creator>Taylor</dc:creator><description>&lt;p&gt;I need to correct my problem.&lt;/p&gt;
&lt;p&gt;I have defined SPI GPIO:&lt;/p&gt;
&lt;p&gt;SCK: P0.4&lt;/p&gt;
&lt;p&gt;MISO: P0.5&lt;/p&gt;
&lt;p&gt;MOSI: P0.6&lt;/p&gt;
&lt;p&gt;SS: P0.7&lt;/p&gt;
&lt;p&gt;And the SPI sensor need another IO write or read to read/write data.&lt;/p&gt;
&lt;p&gt;RST:P0.8&lt;/p&gt;
&lt;p&gt;BUSY: P0.9&lt;/p&gt;
&lt;p&gt;DIO1: P0.10&lt;/p&gt;
&lt;p&gt;Here is my GPIO configration:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define SPI_SCK_PIN    4
#define SPI_MISO_PIN   5
#define SPI_MOSI_PIN   6
#define SPI_SS_PIN     7

#define RADIO_nRESET_PIN  8
#define RADIO_BUSY_PIN    9
#define RADIO_DIO1_PIN    10

nrf_gpio_cfg_input(RADIO_DIO1_PIN, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_input(RADIO_BUSY_PIN, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_output(RADIO_nRESET_PIN);
nrf_gpio_pin_set(RADIO_nRESET_PIN);

nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
//  spi_config.ss_pin   = NRF_DRV_SPI_PIN_NOT_USED;
    spi_config.miso_pin = SPI_MISO_PIN;
    spi_config.mosi_pin = SPI_MOSI_PIN;
    spi_config.sck_pin  = SPI_SCK_PIN;
//	spi_config.frequency = SPI_FREQUENCY_FREQUENCY_K250;
//	spi_config.irq_priority = 4;
	nrf_gpio_cfg_output(SPI_SS_PIN);
    nrf_gpio_pin_set(SPI_SS_PIN);
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When the application worked on nRF52832 custom board, the SPI will read wrong data, I&amp;#39;ll show you&amp;nbsp;&lt;span&gt;logic analyzer trace&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;latter.&lt;/p&gt;
&lt;p&gt;Is the NFC pin occur uncertainly voltage even&amp;nbsp; I defined&amp;nbsp;&lt;span&gt;CONFIG_NFCT_PINS_AS_GPIOS?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ll upload the software or hardware if you need.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;Logic analyzer trace:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/832_2D00_1.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/832.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/50045.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;My application code:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define SPI_SCK_PIN    4
#define SPI_MISO_PIN   5
#define SPI_MOSI_PIN   6
#define SPI_SS_PIN     7

#define RADIO_nRESET_PIN  8
#define RADIO_BUSY_PIN    9
#define RADIO_DIO1_PIN    10

nrf_gpio_cfg_input(RADIO_DIO1_PIN, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_input(RADIO_BUSY_PIN, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_output(RADIO_nRESET_PIN);
nrf_gpio_pin_set(RADIO_nRESET_PIN);
nrf_delay_ms(500);


uint8_t SpiInOut( uint8_t txBuffer)
{
		uint8_t m_rx=0;
		uint32_t timeout = 10000;

		spi_xfer_done = false;
		APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;txBuffer, 1, &amp;amp;m_rx, 1));
		while (!spi_xfer_done)
		{
				__WFE();
		}
		NRF_LOG_INFO(&amp;quot;SPI RX:%02x  TX:%02x&amp;quot;,m_rx,txBuffer);
		return m_rx;
}
void SpiIn( uint8_t *txBuffer, uint16_t size )
{
		uint8_t m_rx_buff[255]={0};
		uint32_t timeout = 10000;
		
		spi_xfer_done = false;
		APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, txBuffer, size, m_rx_buff,NULL));
		while (!spi_xfer_done)
		{
				__WFE();
		}
}

void spi_event_handler(nrf_drv_spi_evt_t const * p_event,
                       void *                    p_context)
{
    spi_xfer_done = true;

}

void m_spi_lora_init(void)
{
		nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
//    spi_config.ss_pin   = NRF_DRV_SPI_PIN_NOT_USED;
    spi_config.miso_pin = SPI_MISO_PIN;
    spi_config.mosi_pin = SPI_MOSI_PIN;
    spi_config.sck_pin  = SPI_SCK_PIN;
//		spi_config.frequency = SPI_FREQUENCY_FREQUENCY_K250;
//		spi_config.irq_priority = 4;
		nrf_gpio_cfg_output(SPI_SS_PIN);
    nrf_gpio_pin_set(SPI_SS_PIN);
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));
		nrf_delay_ms(100);
//		m_lora_init(LORA_INIT_MODE);
		m_lora_check();
		NRF_LOG_INFO(&amp;quot;LORA initialized.&amp;quot;);
}

void m_lora_check(void)
{
		uint8_t data[2]={0x12,0x34};
    uint8_t test[2]={0,0};
		while(1)
		{
    Radio.WriteBuffer(0x06C0,data,2);
    Radio.ReadBuffer(0x06C0,test,2);
		
	
		if((test[0]==data[0])&amp;amp;&amp;amp;(test[1]==data[1]))
		{
				NRF_LOG_INFO(&amp;quot;Lora SUCCESS&amp;quot;);
				m_tag_type.check[TAG_LORA]  = TAG_CHECK_SUCCESS;
		}else
		{
				NRF_LOG_INFO(&amp;quot;Lora FAIL %02x %02x&amp;quot;,test[0],test[1]);
				m_tag_type.check[TAG_LORA] = TAG_CHECK_ERROR;
		}
		nrf_delay_ms(1000);
		NRF_LOG_FLUSH();
	}
}

const struct Radio_s Radio =
{
    RadioInit,
    RadioGetStatus,
    RadioSetModem,
    RadioSetChannel,
    RadioIsChannelFree,
    RadioRandom,
    RadioSetRxConfig,
    RadioSetTxConfig,
    RadioCheckRfFrequency,
    RadioTimeOnAir,
    RadioSend,
    RadioSleep,
    RadioStandby,
    RadioRx,
    RadioStartCad,
    RadioSetTxContinuousWave,
    RadioRssi,
    RadioWrite,
    RadioRead,
    RadioWriteBuffer,
    RadioReadBuffer,
    RadioSetMaxPayloadLength,
    RadioSetPublicNetwork,
    RadioGetWakeupTime,
    RadioIrqProcess,
    // Available on SX126x only
    RadioRxBoosted,
    RadioSetRxDutyCycle
};

void RadioWriteBuffer( uint16_t addr, uint8_t *buffer, uint8_t size )
{
    SX126xWriteRegisters( addr, buffer, size );
}
void SX126xWriteRegisters( uint16_t address, uint8_t *buffer, uint16_t size )
{
    SX126xCheckDeviceReady( );

    nrf_gpio_pin_clear(SPI_SS_PIN);
    
    SpiInOut(RADIO_WRITE_REGISTER );
    SpiInOut(( address &amp;amp; 0xFF00 ) &amp;gt;&amp;gt; 8 );
    SpiInOut( address &amp;amp; 0x00FF );
    
    for( uint16_t i = 0; i &amp;lt; size; i++ )
    {
        SpiInOut(buffer[i] );
    }


    nrf_gpio_pin_set(SPI_SS_PIN);

    SX126xWaitOnBusy( );
}

void RadioReadBuffer( uint16_t addr, uint8_t *buffer, uint8_t size )
{
    SX126xReadRegisters( addr, buffer, size );
}
void SX126xReadRegisters( uint16_t address, uint8_t *buffer, uint16_t size )
{
    SX126xCheckDeviceReady( );

    nrf_gpio_pin_clear(SPI_SS_PIN);

    SpiInOut(RADIO_READ_REGISTER );
    SpiInOut(( address &amp;amp; 0xFF00 ) &amp;gt;&amp;gt; 8 );
    SpiInOut( address &amp;amp; 0x00FF );
    SpiInOut( 0 );
    for( uint16_t i = 0; i &amp;lt; size; i++ )
    {
        buffer[i] = SpiInOut(0 );
    }

    nrf_gpio_pin_set(SPI_SS_PIN);

    SX126xWaitOnBusy( );
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM on nRF52832 and nRF52810</title><link>https://devzone.nordicsemi.com/thread/355312?ContentTypeID=1</link><pubDate>Mon, 28 Feb 2022 14:16:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64866a93-fde1-45fa-b5cd-5a833faf5761</guid><dc:creator>testy</dc:creator><description>&lt;p&gt;TWI (SPI not tested) works for us: using CONFIG_NFCT_PINS_AS_GPIOS and nRF52832 2. rev and P0.2/SCL, P0.9/SDA @100kHz/400kHz.&lt;/p&gt;
&lt;p&gt;Should we expect any troubles?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM on nRF52832 and nRF52810</title><link>https://devzone.nordicsemi.com/thread/355291?ContentTypeID=1</link><pubDate>Mon, 28 Feb 2022 13:32:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19dab087-0c80-4420-a391-292b8ffac2d8</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;We had this intermittent issue when using NFC pins as gpio a couple of years ago. &amp;nbsp;This happened at any speed. &amp;nbsp;It was very hard to find. &amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM on nRF52832 and nRF52810</title><link>https://devzone.nordicsemi.com/thread/355289?ContentTypeID=1</link><pubDate>Mon, 28 Feb 2022 13:28:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60e8c82c-856f-4b94-b5c1-06ad8a398348</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you try to reduce the SPIM speed to see if that impact the issue? Do you have a logic analyzer trace to look at for comparison?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM on nRF52832 and nRF52810</title><link>https://devzone.nordicsemi.com/thread/355216?ContentTypeID=1</link><pubDate>Mon, 28 Feb 2022 10:14:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9c07a10-b836-4535-8448-485e44279be4</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;Do not use the NFC pins with any other peripheral interface such as uart, i2c, spi,... &amp;nbsp;I can use it to flip on/off no problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>