This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MP430 SPI Slave mode and Raspberry PI master

Other Parts Discussed in Thread: CC430F5137

I have a problem reading any data in SPI slave mode on CC430F5137 mC. As a master I use Raspberry Pi 2. Pi is configured correctly and sends correct data (I checked this with oscilloscope). mC do not read any data though. I do not matter ho I configure SPI on mC (clock polarity, phase etc.). I though that it may be problem with 5V Vcc and 3.3V Vcc difference in Pi and mC and used 2 way logic level converter in between but it still do not changed anything. I think speed is also not an issue since 1MHz surely is in capabilities of both devices. I checked physical connections - fine too. The only other thing that might be wrong is software on mC. Here i a code I use:

uint8_t transmitData = 0x01, receiveData = 0x00;

uint8_t returnValue = STATUS_FAIL;

void prog_main(void)
{
    //Stop watchdog timer
    WDT_A_hold(WDT_A_BASE);

    //If clock signal from master stays low, it is not yet in SPI mode
    while ( GPIO_INPUT_PIN_LOW ==
            GPIO_getInputPinValue(
                    GPIO_PORT_P1,
                    GPIO_PIN4
                    )) ;

    GPIO_setAsPeripheralModuleFunctionInputPin(
            GPIO_PORT_P1,
            GPIO_PIN2 +
            GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN7
            );


    returnValue = USCI_B_SPI_slaveInit(USCI_B0_BASE,
                                       USCI_B_SPI_MSB_FIRST,
                  USCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
                  USCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW
                                       );

    if (STATUS_FAIL == returnValue)
            return;

    //Enable SPI Module
    USCI_B_SPI_enable(USCI_B0_BASE);

    //Enable Receive interrupt
    USCI_B_SPI_clearInterruptFlag(USCI_B0_BASE,
                                  USCI_B_SPI_RECEIVE_INTERRUPT
                                  );
    USCI_B_SPI_enableInterrupt(USCI_B0_BASE,
                               USCI_B_SPI_RECEIVE_INTERRUPT
                               );

    //Enter LPM4, enable interrupts
    __bis_SR_register(
                      LPM4_bits + 
                        GIE);
}

uint8_t a=0;
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_B0_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(USCI_B0_VECTOR)))
#endif
void USCI_B0_ISR(void)
{
        switch (__even_in_range(UCB0IV, 4)) {
        //Vector 2 - RXIFG
        case 2:
                //USCI_A0 TX buffer ready?
                while (!USCI_B_SPI_getInterruptStatus(USCI_B0_BASE,
                                                      USCI_B_SPI_TRANSMIT_INTERRUPT
                                                      ));

                //Transmit data to master
                USCI_B_SPI_transmitData(USCI_B0_BASE,
                                        transmitData
                                        );

                //Receive data from master
                receiveData = USCI_B_SPI_receiveData(USCI_B0_BASE);
                if(receiveData!=0)
                {
                  //Increment data to be transmitted
                  transmitData++;
                }

                break;

        default: break;
        }
}

**Attention** This is a public forum