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.

我想要將msp432p401r的example code 複製到新的空白CCS文件中,可是他會錯誤

我想要在CCS中將MSP432{401R的UART範例CODE和SPI範例CODE做結合,讓我所設計的程式可以進行編成,首先我把UART範例CODE複製到一個全新的空白檔案中,接著我讓它嘗試運轉,看是否出現問題,結果出現了以下問題如附圖,我不知道該如何解決它。

  • 应该是您的路径设置问题,您是否有正确地包含driverlib?另外还有符号的缺少

    若是可以的话,请您将您的代码发送过来,谢谢
  • 你好:
    我的代碼其實就單純是官方的EXAMPLE,但我不知道為什麼將代碼複製到另一個新的空白專案會無法執行,造成上述問題,對於代碼方面,沒有作任何更動。

    /* --COPYRIGHT--,BSD
    * Copyright (c) 2017, 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.
    * --/COPYRIGHT--*/
    /******************************************************************************
    * MSP432 UART - PC Echo with 12MHz BRCLK
    *
    * Description: This demo echoes back characters received via a PC serial port.
    * SMCLK/DCO is used as a clock source and the device is put in LPM0
    * The auto-clock enable feature is used by the eUSCI and SMCLK is turned off
    * when the UART is idle and turned on when a receive edge is detected.
    * Note that level shifter hardware is needed to shift between RS232 and MSP
    * voltage levels.
    *
    * MSP432P401
    * -----------------
    * | |
    * | |
    * | |
    * RST -| P1.3/UCA0TXD|----> PC (echo)
    * | |
    * | |
    * | P1.2/UCA0RXD|<---- PC
    * | |
    *
    *******************************************************************************/
    /* DriverLib Includes */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>

    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>

    //![Simple UART Config]
    /* UART Configuration Parameter. These are the configuration parameters to
    * make the eUSCI A UART module to operate with a 9600 baud rate. These
    * values were calculated using the online calculator that TI provides
    * at:
    *software-dl.ti.com/.../index.html
    */
    const eUSCI_UART_Config uartConfig =
    {
    EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
    78, // BRDIV = 78
    2, // UCxBRF = 2
    0, // UCxBRS = 0
    EUSCI_A_UART_NO_PARITY, // No Parity
    EUSCI_A_UART_LSB_FIRST, // LSB First
    EUSCI_A_UART_ONE_STOP_BIT, // One stop bit
    EUSCI_A_UART_MODE, // UART mode
    EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling
    };
    //![Simple UART Config]

    int main(void)
    {
    /* Halting WDT */
    MAP_WDT_A_holdTimer();

    /* Selecting P1.2 and P1.3 in UART mode */
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
    GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);

    /* Setting DCO to 12MHz */
    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);

    //![Simple UART Example]
    /* Configuring UART Module */
    MAP_UART_initModule(EUSCI_A0_BASE, &uartConfig);

    /* Enable UART module */
    MAP_UART_enableModule(EUSCI_A0_BASE);

    /* Enabling interrupts */
    MAP_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);
    MAP_Interrupt_enableInterrupt(INT_EUSCIA0);
    MAP_Interrupt_enableSleepOnIsrExit();
    MAP_Interrupt_enableMaster();
    //![Simple UART Example]

    while(1)
    {
    MAP_PCM_gotoLPM0();
    }
    }

    /* EUSCI A0 UART ISR - Echoes data back to PC host */
    void EUSCIA0_IRQHandler(void)
    {
    uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A0_BASE);

    MAP_UART_clearInterruptFlag(EUSCI_A0_BASE, status);

    if(status & EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG)
    {
    MAP_UART_transmitData(EUSCI_A0_BASE, MAP_UART_receiveData(EUSCI_A0_BASE));
    }

    }
  • 我测试了一下您的代码,并没有出现错误。
  • 我發現我的專案中的Debug資料夾內無法生成OUTPUT檔,如原文第一張圖所示,COULD NOT OPEN的原因是沒有生成OUT那個檔案,請問有辦法解決嗎?
  • 可以說明一下,測試代碼的步驟以及CCS的版本嗎?
  • 我将您之前发的程序复制到工程中,用的是CCS9

  • 我懷疑是有一些需要導入的項目未導入,導致無法正常運行,雖然我不知到需要導入什麼,不過從範例程式碼直接做更動,不要開新的專案就可以正常運行了