Hi ,
Need a bit of help here.
I am trying to use TWI and SPI in a single code for communicating with two different slave devices, the LTC2941 coulomb counter and the EM4325 RFID tag. I have written a switch case program similar to the one given in SDK 12.3.0 , and added an SPI case for the same. Here is a snippet of my main function (it is similar to the twis_master_with_twis_slave code provided in the SDK) :
EM4325 datasheet : http://www.emmicroelectronic.com/products/rf-identification-security/epc-and-uhf-ics/em4325
LTC 2941 datasheet : http://cds.linear.com/docs/en/datasheet/2941fb.pdf
Here is the rfid_spi() function which is being called inside the switch case statement for communicating with EM4325 :
Fullscreen123456789101112131415161718192021static void rfid_spi(void){uint32_t spike_clk = 24 ;uint32_t spike_miso = 23;uint32_t spike_mosi = 22 ;nrf_spim_enable( (NRF_SPIM_Type *)SPI_INSTANCE);//nrf_spim_event_clear((NRF_SPIM_Type *)SPI_INSTANCE , NRF_SPI_EVENT_READY ) ;nrf_spim_configure((NRF_SPIM_Type *) SPI_INSTANCE , NRF_SPIM_MODE_0 , NRF_SPIM_BIT_ORDER_MSB_FIRST) ;nrf_spim_pins_set( (NRF_SPIM_Type *)SPI_INSTANCE , spike_clk ,spike_mosi, spike_miso ) ;nrf_spim_frequency_set((NRF_SPIM_Type *)SPI_INSTANCE, NRF_SPIM_FREQ_250K);// nrf_spim_int_enable ((NRF_SPIM_Type *)SPI_INSTANCE,SPI_INTENSET_READY_Set) ;//memset(m_rx_buf, 0, 20); //m_lengthspi_xfer_done = false;I am using the SPIM HAL to communicate with EM4325, this is because when I tried to integrate the spi and twi master codes (of SDK 12.3) , it was giving me garbage values in the receive buffer of the SPI, hence I tried to use the HAL. When I used the SPIM HAL, .( I have referred to the following webpage for using the HAL, my SPI Instance is 2 and TWI instance is 0 ----- https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk52.v0.9.2%2Fgroup__nrf__spim__hal.html )
I tried to use the event check function but it was returning me zero values , which indicated that the SPI was not being initiated by the HAL functions
What is the reason for this?? I have attached the serial window output below:
Can someone please help me with a switch case code in which I can use SPI for one switch case and I2C for another ? Is it possible to do this using HAL or with the API which have been provided in SDK 12.3 itself?
Also, when do I know if I should use EASY DMA or not?
Thanking you in advance,
Kunal.