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

nrf51822 + temp sensor problem spi rx

Hello.

I use nrf51822 EK and TN-901 temp sensor. My plan is nrf51822 slave, TN-901 is master or considering the roles reverse. Getting value is spi and output is uart. But i don't know how to get value in spi. Upload my source and sheet.

Please advise.

Thank you.

TN-901_Datasheet.pdf

spi_master.zip

Parents
  • FormerMember
    0 FormerMember

    I think it will be easier if you use the spi_master.c and .h files that is in the SDK. With this you could do something like this

    #include "spi_master.h"
    #include "simple_uart.h"
    #include "spi_master_config.h"
    #include "nrf_delay.h"
    main(){
        simple_uart_config( required parameters );
        spi_master_init( required parameters );
        while(1){
            spi_master_tx_rx( parameters );
            spi_master_tx_rx( parameters );    //Receive MSB here
            spi_master_tx_rx( parameters );    //Receive LSB here
            spi_master_tx_rx( parameters );    
            spi_master_tx_rx( parameters );
    
            character string with MSB and LSB with required formatting
            simple_uart_put_string( temp_string ); 
            nrf_delay_ms(1000);
        }
    }
    

    With this you need not touch any registers in main and the code is more elegant. Hope this helps, Prithvi

  • Thank u Prithvi, the temp sensor to generate a frequency of 2kHz, so I want to slave way.. What should I do? I want receive only..

Reply Children
No Data
Related