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

SPI MOSI only

Hi All,

I am trying to make a nrf51822 talk to a SPI display by using the SPI Master. My problem is that the display does not give any output, only takes input.

The nrf51822 SPI Master seems to expect that whenever it sends a byte on TX, it should also receives a byte on RX, otherwise the EVENTS_READY flag just won't be set.

It seems like my only options are

*Bitbang the message myself.

*Use nrf51822's SPI slave, and provide my own clock, as suggested here Title

I suppose shorting my SPI output to another pin, and set that pin to MISO will do, but for hardware reasons I can't really do that.

Thanks for your time in advance, Felix

  • Have you tried connection the display and the nRF51? As long as you read out the SPI buffer on the nRF51 it shouldn't matter whether or not the data on the MISO line is actually worth using. If the pin is left open the buffer will still be filled with random data while you write to the display one the MOSI line. Just clear and throw away the content of the MISO and you should be fine.

  • Hi,

    I am facing a similar Problem where my slave device only has a MOSI and it does not communicate back with the nrf518222. Hence, I have connected the MISO to a dummy pin which is left open.

        bool spi_master_tx(SPIModuleNumber spi_num, uint16_t transfer_size, const uint8_t *tx_data)
    {
        volatile uint32_t dummyread;
    		uint16_t delay;	
    	
        if(tx_data == 0)
        {
            return false;
        }
        
    		delay = 0x3E80;										// 1ms delay for 16MHz clock
        SPI = spi_base[spi_num];
        
        /* enable slave (slave select active low) */
        nrf_gpio_pin_clear(spi_config_table[spi_num].Pin_CSN);
        
        SPI->EVENTS_READY = 0; 
        
        SPI->TXD = (uint32_t)*tx_data++;	
    		
        
        while(--transfer_size)
        {
            SPI->TXD =  (uint32_t)*tx_data++;		
    
    				
            /* Wait for the transaction complete or timeout (about 10ms - 20 ms) */
            while (SPI->EVENTS_READY == 0 && --delay);
            
            /* clear the event to be ready to receive next messages */
            SPI->EVENTS_READY = 0;
            
            dummyread = SPI->RXD;
        }   
    		
    		delay = 0x3E80;										// 1ms delay for 16MHz clock
        /* Wait for the transaction complete or timeout (about 10ms - 20 ms) */
    		while (SPI->EVENTS_READY == 0 && --delay);
    
        dummyread = SPI->RXD;
    
        /* disable slave (slave select active low) */
        nrf_gpio_pin_set(spi_config_table[spi_num].Pin_CSN);
        
        return true;
    }
    

    This is the code snippet which I am using to Transfer data to my slave. But the Problem is that the EVENT_READY is never set and I Exit the Loop only after my defined delay (no matter how Long the delay).

    As mentioned in the user Manual, since the EVENT_READY is set only when data is written to the RXD Register. Now since my MISO is left open I will never receive data into the RXD Register. Is there a Workaround for this. How did you solve your Problem?

    Thanks, Richard

  • Which WHILE loop do you exit by delay timeout? First or second? I suspect second WHILE loop not needed at all.

  • Hi Alex,

    Both the while Loops I my exiting through my timeout. The EVENT_READY is never generated.
    And yes, you are correct, the second is not requied.

    Is the EVENT_READY Event generated even there is no Change in the RXD Register as the MISO pin is just connected to a dummy pin.

  • RXD register will be changed during TXD regardless of what is on MISO pin. As Asbjørn said earlier, RXD register will just have random data, in your case either 0x00 or oxFF depending on the constant level of dummy pin

Related