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

Parents
  • 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

  • I'd remove first line of

    SPI->TXD = (uint32_t)*tx_data++;
    

    and leave only one in WHILE loop

Reply Children
No Data
Related