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.

[参考译文] CCS/MSP-EXP432P401R:Arduino Uno 至 MSP432串行通信

Guru**** 2618835 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/677470/ccs-msp-exp432p401r-arduino-uno-to-msp432-serail-communication

器件型号:MSP-EXP432P401R

工具/软件:Code Composer Studio

我正在尝试在 Arduino uno 和 msp432之间进行项目通信。 我将以9600 bps 的速率从 Arduino 发送数据。 我将 Arduino 的 TX 引脚连接到 msp432上的端口3引脚2。 为了测试这一点、我基本上只发送 int 值1、然后将该值存储在 MSP 代码中的 int 变量中。 但是、我没有得到我所期望的结果(LED 闪烁)。 有人可以帮助我调试这个吗? 以下是我将用于两个 MSP 的代码:  

MSP 代码:  

#include "msp.h"

#include "driverlib.h"

volatile int data = 0;

const eUSCI_UART_Config uartConfig =

  EUSCI_A_UART_CLOCKSOURCE_SMCLK、      // SMCLK 时钟源

  78、                    // BRDIV = 78

  2、                    // UCxBRF = 2

  0、                    // UCxBRS = 0

  EUSCI_A_UART_NO_奇 偶校验、          //无奇偶校验

  EUSCI_A_UART_LSB_FIRST、          // MSB 优先

  EUSCI_A_UART_One_stop_bit、        //一个停止位

  EUSCI_A_UART_MODE、            // UART 模式

  EUSCI_A_UART_oversampling_BAUDRATE_generation //过采样

};

/**

 * main.c

 *

void main (void)

  WDT_A_HOLDTimer();

  GPIO_setAsOutputPin (GPIO_PORT_P2、GPIO_PIN2);

  GPIO_setOutputLowOnPin (GPIO_PORT_P2、GPIO_PIN2);

  GPIO_setPeripheralModuleFunctionInputPin (GPIO_PORT_P3、GPIO_PIN2 | GPIO_PIN3、GPIO_PRIMARY_MODULE_Function);

  /*配置 UART 模块*/

  UART_initModule (EUSCI_A2_base、uartConfig);

  /*启用 UART 模块*/

  UART_enableModule (USCI_A2_base);

  /*启用中断*/

  UART_enableInterrupt (EUSCI_A2_base、 EUSCI_A_UART_receive_interrupt);

  INTERRUPT_enableInterrupt (INT_EUSCIA2);

  interrupt_enableSlepOnIsrExit();

  interrupt_enableMaster();

  while (1){

  }

void EUSCIA0_IRQHandler (void){

  GPIO_toggleOutputOnPin (GPIO_PORT_P2、 GPIO_PIN2);

  数据= UART_receiveData (EUSCI_A2_base);

  if (data>0){

    GPIO_toggleOutputOnPin (GPIO_PORT_P2、 GPIO_PIN2);

  }

  UART_clearInterruptFlag (EUSCI_A2_base、EUSCI_A_UART_receive_interrupt);

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好、Madison、

    您使用的是 USCI A2、但具有 EUScI-A0的中断处理程序 EUSCIA0_IRQHandler。 相反、将中断处理程序函数更改为 EUSCIA2_IRQHandler (