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.

5418A communicate with DSP6670 via SPI

Other Parts Discussed in Thread: MSP430F5418A

Hi all,

I'm currently working on 5418A SPI project. All I wanna do is to communicate with 6670 via SPI bus. In the process, DSP is master and MCU is slave.After initializing SPI,

I can't receive data correctly. DSP send one byte at a time. And MCU save the data. MCU configured in slave, MSB first, 4 pin with CS pin active low,

synchronous mode. Do I have to configure the clock source in the MCU program? DSP send data 0x01, 0x02, 0x03, 0x04... respectively. But MCU received data are 0x00,

0x80, 0x81, 0x01, 0x82, 0x02... Could you tell me why? Are there anything wrong with the configuration SPI?

Thanks a lot

Best regards,

Nick

  • I think you need to provide some additional information in terms of your configuration on the MSP430 side.

    Have you verified the Digital I/O ports of the MSP430 are configured for the SPI peripheral mode versus GPIO mode?

    There are C code examples for the MSP430F5418A on its Product Folder that you could review to help you configure the peripheral appropriately.  There should be at least 1 example that configures the USCI in a SPI slave mode.

     

    Also, have you verified the DSP is truly sending data as you expect it via an oscilloscope, etc?

  • Hi Brandon,

    Yes, in the port_init function I configure the I/O port for the SPI peripheral mode. The following is the snippet of my code:

     

    void test_mcu_port_init(void)

    {

        P1SEL |= 0x00;

        P1DIR |= 0x5b;

        P2SEL |= 0x00;

        P2DIR |= 0xe7;

        P3SEL |= 0xbf;

        P3DIR |= 0x42;

        P4SEL |= 0x59;

        P4DIR |= 0xae;

        P5SEL |= 0xd0;

        P5DIR |= 0x25;

        P6SEL |= 0x03;

        P6DIR |= 0x78;

        P7SEL |= 0x0b;

        P7DIR |= 0xb4;

        P8SEL |= 0x00;

        P8DIR |= 0x3f;

    }

    void test_mcu_spi_init(void)

    {

        UCB0CTL1 |= UCSWRST;                                      

        UCB0CTL0 |= UCSYNC + UCCKPL + UCMODE_2 + UCMSB;           

        UCB0CTL1 &= ~UCSWRST;                                     

        UCB0IE   |= UCRXIE;                                       

        __bis_SR_register(GIE); 

    }

    And I'm sure that DSP is truly sending the data as I expect. But I can't receive data correctly. Are there anything wrong in my initialization code?

    BTW, DSP SPI clock is 1MHz and send one byte at a time in MSB mode.

    Thanks

    Best regards,

    Nick

  • Nick Carter said:
    Are there anything wrong in my initialization code?

    Maybe a problem with phase/polarity.

    Also, what is your MSP CPU clock speed?
    Receiving wiht 1MHz means 8µs per byte. Or 8 MCLK cycles when the CPU is running on 1MHz. The latency (entry/exit code) for an ISR is larger than 8 MCLK cycles (11 cycles plus code inside the ISR).

    unless your MSP runs much faster than 1MHz, you're losing data.

**Attention** This is a public forum