This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52832 read ADXL362 chip id

I am working on reading ADXL362 through SPI on PCA10040.I used demo spi in nRF5_SDK_13.1.0. here is my main code:

bsp_board_leds_init();

APP_ERROR_CHECK(NRF_LOG_INIT(NULL));

NRF_LOG_INFO("SPI example\r\n");

nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin   = SPI_SS_PIN;
spi_config.miso_pin = SPI_MISO_PIN;
spi_config.mosi_pin = SPI_MOSI_PIN;
spi_config.sck_pin  = SPI_SCK_PIN;
APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));
while (1)
{
    memset(m_rx_buf, 0, m_length);
    memset(m_tx_buf, 0, m_length);
    m_tx_buf[0] = 0x0b;
    m_tx_buf[1] = 0x02;
    
    spi_xfer_done = false;

    APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, 3, m_rx_buf, 3));

    while (!spi_xfer_done)
    {
        __WFE();
    }
    NRF_LOG_INFO("%x\r\n", m_rx_buf[2]);
    NRF_LOG_FLUSH();

    bsp_board_led_invert(BSP_BOARD_LED_0);
    nrf_delay_ms(200);
}

in the beginning, i received nothing but 0x00. then according to nRF52832- why when using nrf_drv_spi with an ADXL362 I need to set the clock in high drive (H0H1)and nrf52 recieves wrong SPI memory flash ID ,i tried to change CLK pin to NRF_GPIO_PIN_H0H1.but no effect.then i changed MISO pin to NRF_GPIO_PIN_PULLUP,i could receive a data of 0xf3,but not 0xf2 according to ADXL362's datasheet.I also tried other register addr,like 0x00 and 0x01.the data received was also incorrect.then i am confused.has anyone know the reasons?

Parents
  • I get it!!! I used to connect MISO to pin 28 same as spi demo of SDK 13.1.0.my colleague remind me that there is something difference between the pins.then I found this in nRF52 Product Specification image description it said that pin 22~31's recommended usage is low drive and low frequency only.then i slow the spi's frequency to 125K,but problem remain.i changed MISO's pin to pin 2. things changed!!!everything gone well.I tried pin 30 and 31 later.the fault appeared again. now although problem solved,but i don't know the reasons.I want to make it clear.so i still need your helps.

Reply
  • I get it!!! I used to connect MISO to pin 28 same as spi demo of SDK 13.1.0.my colleague remind me that there is something difference between the pins.then I found this in nRF52 Product Specification image description it said that pin 22~31's recommended usage is low drive and low frequency only.then i slow the spi's frequency to 125K,but problem remain.i changed MISO's pin to pin 2. things changed!!!everything gone well.I tried pin 30 and 31 later.the fault appeared again. now although problem solved,but i don't know the reasons.I want to make it clear.so i still need your helps.

Children
No Data
Related