I am using SPI0 of nrf52.Following is the code:
I am using SPI0 of nrf52.Following is the code:
Can you please try to tidy up your code? Remove all the code that is not necessary and show us how exactly you are initiating the SPI and how you do read and write operations.
Hi, I am able to read the register value of ADXL362 accelerometer into nrf52 with slight modification with previous code.Modifications are:
void read(nrf_drv_spi_t const * p_instance, uint8_t reg){
m_tx_data_spi[0] = 0x0B;
m_tx_data_spi[1] = reg;
m_tx_data_spi[2] = 0x00;
// m_rx_data_spi[2] = 0;
uint32_t err_code = nrf_drv_spi_transfer(p_instance,
m_tx_data_spi, 3, m_rx_data_spi, 3);
print(m_rx_data_spi[2]);
}
void print(unsigned char p)
{
static char buff[4]={0};
sprintf(buff,"%x",p);
app_uart_put(buff[0]);
app_uart_put(buff[1]);
app_uart_put(0x0A);
app_uart_put(0x0D);
nrf_delay_ms(DELAY_MS*10);
}
Hi, I am able to read the register value of ADXL362 accelerometer into nrf52 with slight modification with previous code.Modifications are:
void read(nrf_drv_spi_t const * p_instance, uint8_t reg){
m_tx_data_spi[0] = 0x0B;
m_tx_data_spi[1] = reg;
m_tx_data_spi[2] = 0x00;
// m_rx_data_spi[2] = 0;
uint32_t err_code = nrf_drv_spi_transfer(p_instance,
m_tx_data_spi, 3, m_rx_data_spi, 3);
print(m_rx_data_spi[2]);
}
void print(unsigned char p)
{
static char buff[4]={0};
sprintf(buff,"%x",p);
app_uart_put(buff[0]);
app_uart_put(buff[1]);
app_uart_put(0x0A);
app_uart_put(0x0D);
nrf_delay_ms(DELAY_MS*10);
}