Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

MSP430FR5994: Two way SPI example

$
0
0

Part Number:MSP430FR5994

Hi,

I am trying to communicate with an SPI-enabled external device from an MSP430FR5994. I have successfully tested the MSP430ware driverlib functions to transmit a byte and I can see on my scope that I get cs, data and clock as I expect. However, the device I am trying to communicate with uses a three byte protocol with first byte being a register address and the following two being read or write data. My problem is now, that I do not manage to read anything after my first byte. Basically by function looks like (which is not implementing the correct three-byte protocol yet, but is a test):

unsigned char res _read(unsigned char * port_ss, unsigned char pin_ss, unsigned char addr) {
    *port_ss &= pin_ss; // Set CS low
    EUSCI_B_SPI_transmitData(EUSCI_B1_BASE, addr);
    while (!EUSCI_B_SPI_getInterruptStatus(EUSCI_B1_BASE,
              EUSCI_B_SPI_TRANSMIT_INTERRUPT));
    EUSCI_B_SPI_transmitData(EUSCI_B1_BASE, addr);
    uint8_t byte1 = EUSCI_B_SPI_receiveData(EUSCI_B1_BASE);
    *port_ss |= pin_ss; // Set CS high
    unsigned char res = byte1
    return res;
}

There might be some trivial error in the code above since I removed any clutter and device specific stuff and might have missed something, but from more or less the code above I get the following on my scope:

Hence, the two issues I have are

1. The large time gap between the two sent bytes - it is due to the interrupt from the EUSCI_B_SPI_getInterruptStatus, but why is it so long and is there some other way I should send two consecutive bytes to make them transmitted directly?

2. I get nothing during the EUSCI_B_SPI_receiveData. No clock no nothing. But there is a delay which I can see if I look at the ss and using an Rx interrupt wait.

A working example where several bytes are tx'ed and rx'ed using driverlib would be highly appreciated!

Great-full for any input!


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>