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.

MSP430FR2433: spi示例代码咨询

Part Number: MSP430FR2433
Other Parts Discussed in Thread: MSP-EXP430FR2433

msp430fr243x_euscia0_spi_09.c (ti.com)

msp430fr243x_euscia0_spi_10.c (ti.com)

我们使用两个MSP-EXP430FR2433模块测试上述两个示例代码功能,但是在CCS内查看对应参数配置,好像没有数据传输?可以解释一下这两个示例代码吗?我们该怎样查看示例代码是否工作正常?

  • 可以解释一下这两个示例代码吗?

    示例说明可以在您给出的链接内查看

    //******************************************************************************
    // MSP430FR243x Demo - eUSCI_A0, SPI 3-Wire Master Incremented Data
    //
    // Description: SPI master talks to SPI slave using 3-wire mode. Incrementing
    // data is sent by the master starting at 0x01. Received data is expected to
    // be same as the previous transmission TXData = RXData-1.

    //******************************************************************************
    // MSP430FR243x Demo - eUSCI_A0, SPI 3-Wire Slave Data Echo
    //
    // Description: SPI slave talks to SPI master using 3-wire mode. Data received
    // from master is echoed back.

    但是在CCS内查看对应参数配置,好像没有数据传输

    您是按照图示来连接两个板子的?观察的是 RXData 和 TXData?

  • Hi Susan Yang

         

    我使用两个个MSP-EXP430FR2433模块分别烧录msp430fr243x_euscia0_spi_09.cmsp430fr243x_euscia0_spi_10.c示例代码。

    我尝试在master这端添加断点参数打印,读取到的RXData和UCA0TXBUF不会有任何改变,RXData一直是255,UCA0TXBUF一直是0x00050E,。我保证从设备先于主设备工作。

  • 谢谢反馈。我拿板子测试后给您回复

  • 请去除 两个开发板上 J101的RXD 和 TXD 跳线帽,另外两个板子的GND也连接在一起

  • Hi Susan Yang
        我们尝试拔掉 J101的RXD 和 TXD 跳线帽,再次进行测试,使用同样的示例代码,但是打印的TxData和RxData与你测试情况不符,请帮助确认一下,谢谢。

  • 附上我的测试代码

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2014, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430FR243x Demo - eUSCI_A0, SPI 3-Wire Master Incremented Data
    //
    //   Description: SPI master talks to SPI slave using 3-wire mode. Incrementing
    //   data is sent by the master starting at 0x01. Received data is expected to
    //   be same as the previous transmission TXData = RXData-1.
    //   USCI RX ISR is used to handle communication with the CPU, normally in LPM0.
    //   ACLK = ~32.768kHz, MCLK = SMCLK = DCO ~ 1MHz.  BRCLK = SMCLK/2.
    //
    //
    //                   MSP430FR2433
    //                 -----------------
    //             /|\|                 |
    //              | |                 |
    //              --|RST              |
    //                |                 |
    //                |             P1.4|-> Data In (UCA0SIMO)
    //                |                 |
    //                |             P1.5|<- Data OUT (UCA0SOMI)
    //                |                 |
    //                |             P1.6|-> Serial Clock Out (UCA0CLK)
    //
    //
    //   Ling Zhu
    //   Texas Instruments Inc.
    //   Sept 2015
    //   Built with IAR Embedded Workbench v6.20 & Code Composer Studio v6.0.1
    //******************************************************************************
    #include <msp430.h>
    
    unsigned char RXData = 0;
    unsigned char TXData;
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;                 // Stop watchdog timer
    
        P1SEL0 |= BIT4 | BIT5 | BIT6;             // set 3-SPI pin as second function
    
        UCA0CTLW0 |= UCSWRST;                     // **Put state machine in reset**
        UCA0CTLW0 |= UCMST|UCSYNC|UCCKPL|UCMSB;   // 3-pin, 8-bit SPI master
                                                  // Clock polarity high, MSB
        UCA0CTLW0 |= UCSSEL__SMCLK;               // SMCLK
        UCA0BR0 = 0x01;                           // /1, fBitClock = fBRCLK/UCBRx
        UCA0BR1 = 0;                              //
        UCA0MCTLW = 0;                            // No modulation
        UCA0CTLW0 &= ~UCSWRST;                    // **Initialize USCI state machine**
        UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
        TXData = 0x01;                            // Holds TX data
    
        PM5CTL0 &= ~LOCKLPM5;                     // Disable the GPIO power-on default high-impedance mode
                                                  // to activate previously configured port settings
        while(1)
        {
            UCA0IE |= UCTXIE;                     // Enable TX interrupt
            __bis_SR_register(LPM0_bits | GIE);   // enable global interrupts, enter LPM0
            __no_operation();                     // For debug,Remain in LPM0
            __delay_cycles(2000);                 // Delay before next transmission
            TXData++;                             // Increment transmit data
        }
    }
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
        switch(__even_in_range(UCA0IV,USCI_SPI_UCTXIFG))
        {
            case USCI_NONE: break;                // Vector 0 - no interrupt
            case USCI_SPI_UCRXIFG:
                  RXData = UCA0RXBUF;
                  UCA0IFG &= ~UCRXIFG;
                  __bic_SR_register_on_exit(LPM0_bits);// Wake up to setup next TX
                  break;
            case USCI_SPI_UCTXIFG:
                  UCA0TXBUF = TXData;             // Transmit characters
                  UCA0IE &= ~UCTXIE;
                  break;
            default: break;
        }
    }
    

  • Hi Susan Yang

        我尝试对比master端代码,没有任何差异,请问CCS内你是怎样调试的?也是通过断电打印参数吗?是否有某些特殊的配置?

  • 也是通过断电打印参数吗?

    我没有设置断点,而是全速运行后暂停,而后查看RXData和 TXData的值

    SPI有时序要求,不建议打断点