打印
[MCU]

MSP432 Lab3 UART and SPI

[复制链接]
558|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
In this lab, we will play with the uart interface of the MSP432. We will explore two options of using UART: driverlib and TI Drivers.
Task 1: MSP432 UART module
In the functional diagram of MSP432 in MSP432 datasheet, we know there are multiple peripheral units.
The UART, I2C, SPI are in the module of Enhanced Universal Serial Communication Interface (eUSCI)
  • The eUSCI modules are used for serial data communication. The eUSCI module supports synchronous communication protocols such as SPI (3-pin or 4-pin) and I2C, and asynchronous communication protocols such as UART, enhanced UART with automatic baud-rate detection, and IrDA.
MSP432 eUSCI contains the following modules as shown in the MSP432 datasheet.
  • Up to Four eUSCI_A Modules
    • UART With Automatic Baud-Rate Detection
    • IrDA Encode and Decode
    • SPI (up to 16 Mbps)
  • Up to Four eUSCI_B Modules
    • I2C (With Multiple-Slave Addressing)
    • SPI (up to 16 Mbps)

  • In the pin diagram, we have two UART ports
  • In MSP432
    Technical Reference Manual (pdf) page. 903
    • The eUSCI_A module supports two serial communication modes: • UART mode • SPI mode
    • In asynchronous mode, the eUSCI_Ax modules connect the device to an external system through two external pins, UCAxRXD and UCAxTXD. UART mode is selected when the UCSYNC bit is cleared.
  • The overall diagram shows the eUSCI_Ax when configured for UART mode
  • For a given BRCLK clock source, the baud rate used determines the required division factor N: N = fBRCLK / baud rate
  • The division factor N is often a noninteger value, thus, at least one divider and one modulator stage is used to meet the factor as closely as possible. If N is equal or greater than 16, it is recommended to use the oversampling baud-rate generation mode by setting UCOS16
  • One online tool to setup the parameters: [link]
  • The UART port pin98/pin99 (P9.6 and P9.7) is routed to the J5 connector in the MSP432 launchpad.
  • Another UART port is pin6 and pin7 ( P1.2_BCLUART_RXD and P1.3_BCLUART_TXD) and connected to the J101 (jumpers connector to the emulation MCU part).
    • You can remove the jumpers of the RXD and TXD on board to disconnect the UART.

  • In this lab, we demo echoes back characters received via a PC serial port. The code is based on the led_toggle sample used in Lab1.
  • Add the following configurations before the main function
    • We select the SMCLK as the clock source (we will configure the SMCLK=12Mhz)
    • The desired baud rate of UART is 9600.
    • The value of BRDIV and others can be accessed via the calculator [link]
    • If N (=fBRCLK/Baudrate)>16, we are enable the oversampling mode via “EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION”

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};
  • Add the following code in the main function
    • We set P1.2 and P1.3 in UART mode. Internal digitally controlled oscillator (DCO) with programmable frequencies and 3-MHz frequency by default. The DCO frequency can be changed during runtime; however, a settling time is required by the DCO before the final selected frequency is obtained.
    • Here we set DCO to 12MHz. The default clock source of MCLK and SMCLK is DCO (check Lab2).
    • That’s why the SMCLK will become 12MHz, the input clock of the eUSCI is BRCLK=12MHz.

/* 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);    /* 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();  
  • Add the following interrupt handler outside of the main
/* 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));    }}
  • Run the code, and connect the COM port (baud rate=9600). You can input the character and the terminal will echo back.
    • You can use the thermal inside the CCS Cloud, or install other thermal software e.g., Tera Term for windows
    • You can use screen command in Mac to access the terminal, e.g, screen -L /dev/cu.usbserial-xxx 115200 –L (where -L turns on output logging so you can see the results of your commands)
  • The complete code is attached
/* DriverLib Includes */#include <ti/devices/msp432p4xx/driverlib/driverlib.h>/* Standard Includes */#include <stdint.h>#include <stdbool.h>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));    }}
In the above code, we set DCO to 12MHz. As 12MHz is a high frequency, we cannot use the MAP_PCM_setPowerMode(PCM_LF_MODE).
  • Run the code, and connect the COM port in CCS Cloud (under Target->connect COM port)
  • After the code running, you will see the following output information.
  • If you are using Tera Term, you should enable the local echo feature to see the echo (under setup->terminal, check Local echo).
  • When you type into the tera, e.g., ‘a’, you will see two ‘a’ return back. If you discontinue the code, you will only see one ‘a’ back.
Question
Please change the UART baud rate to 115200, and submit your revised code to Canvas.
Task 2: SPI Master
The SPI module in the MSP432 can be eUSCI_A or eUSCI_B. After checking the datasheet, we have eUSCI_A0
In the schematic, we know eUSCI_A0 pins are in UART mode, only eUSCI_B0 pins are in SPI mode
These SPI pins are also routed to the boosterpack (J1-J4)
In the page 933 of the MSP432 Technical Reference Manual (pdf) we know the eUSCI SPI diagram is
Three or four signals are used for SPI data exchange:
  • UCxSIMO – slave in, master out Master mode: UCxSIMO is the data output line. Slave mode: UCxSIMO is the data input line.
  • UCxSOMI – slave out, master in Master mode: UCxSOMI is the data input line. Slave mode: UCxSOMI is the data output line.
  • UCxCLK – eUSCI SPI clock Master mode: UCxCLK is an output. Slave mode: UCxCLK is an input.
  • UCxSTE – slave transmit enable Used in 4-pin mode to allow multiple masters on a single bus. Not used in 3-pin mode.
The following figure shows the eUSCI as a master in both 3-pin and 4-pin configurations. The eUSCI initiates data transfer when data is moved to the transmit data buffer UCxTXBUF. The UCxTXBUF data is moved to the transmit (TX) shift register when the TX shift register is empty, initiating data transfer on UCxSIMO starting with either the MSB or LSB, depending on the UCMSB setting. Data on UCxSOMI is shifted into the receive shift register on the opposite clock edge. When the character is received, the receive data is moved from the receive (RX) shift register to the received data buffer UCxRXBUF and the receive interrupt flag UCRXIFG is set, indicating that the RX or TX operation is complete.
The following figure shows the eUSCI as a slave in both 3-pin and 4-pin configurations. UCxCLK is used as the input for the SPI clock and must be supplied by the external master. The data-transfer rate is determined by this clock and not by the internal bit clock generator. Data written to UCxTXBUF and moved to the TX shift register before the start of UCxCLK is transmitted on UCxSOMI. Data on UCxSIMO is shifted into the receive shift register on the opposite edge of UCxCLK and moved to UCxRXBUF when the set number of bits are received. When data is moved from the RX shift register to UCxRXBUF, the UCRXIFG interrupt flag is set, indicating that data has been received. The overrun error bit UCOE is set when the previously received data is not read from UCxRXBUF before new data is moved to UCxRXBUF.
To configure the eUSCI SPI master mode, we can add the following code to configure the eUSCI SPI master mode
  • Add the following code to the UART code in Task1.
/* SPI Master Configuration Parameter */const eUSCI_SPI_MasterConfig spiMasterConfig ={        EUSCI_B_SPI_CLOCKSOURCE_SMCLK,             // SMCLK Clock Source        12000000,                                   // SMCLK = DCO = 12MHZ        500000,                                    // SPICLK = 500khz        EUSCI_B_SPI_MSB_FIRST,                     // MSB First        EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,    // Phase        EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH, // High polarity        EUSCI_B_SPI_3PIN                           // 3Wire SPI Mode};
We set SPI clock source BRCLK=SMCLK=12000000, SPICLK=500Khz. The data structure of the SPI master configure can be accessed here: [driverlib manual]. The data fields are
The SPI configuration data structure is need by SPI_initMaster
From Driverlib manual
The explanation of the MasterConfigure structure is
To enable the SPI master, we should add the following code inside the main function
/* Selecting P1.5 P1.6 and P1.7 in SPI mode */    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,            GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);    /* Configuring SPI in 3wire master mode */    SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig);    /* Enable SPI module */    SPI_enableModule(EUSCI_B0_BASE);
We first enable the P1.5, P1.6, and P1.7 as the primary peripheral module (SPI), then utilize SPI_initMaster to initialize the SPI in 3 wire master mode and enable SPI module via SPI_enableModule.
When the SPI master received data, we should utilize the interrupt to received the data instead of constant polling. We utilize the following code to enable the SPI interrupt
/* Enabling interrupts */    SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT);    Interrupt_enableInterrupt(INT_EUSCIB0);    Interrupt_enableSleepOnIsrExit();
The interrupt routine is added as follows
//******************************************************************************////This is the EUSCI_B0 interrupt vector service routine.////******************************************************************************void EUSCIB0_IRQHandler(void){    uint32_t status = SPI_getEnabledInterruptStatus(EUSCI_B0_BASE);    uint32_t jj;    SPI_clearInterruptFlag(EUSCI_B0_BASE, status);    if(status & EUSCI_B_SPI_RECEIVE_INTERRUPT)    {        /* USCI_B0 TX buffer ready? */        while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));        RXData = SPI_receiveData(EUSCI_B0_BASE);        /* Send the data packet */        MAP_SPI_transmitData(EUSCI_B0_BASE, 'a');        /* Delay between transmissions for slave to process information */        for(jj=50;jj<50;jj++);    }}
The definition of the SPI_getInterruptStatus is from the [driverlib manual]
The EUSCI_A_SPI_receiveData received one byte from the SPI.
The SPI master should send one data first, thus we add the following code in the main function
/* Polling to see if the TX buffer is ready */    while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT)));    /* Transmitting data to slave */    SPI_transmitData(EUSCI_B0_BASE, TXData);Task 3: SPI Slave
To enable the SPI slave, we can utilize the following configuration
/* SPI Slave Configuration Parameter */const eUSCI_SPI_SlaveConfig spiSlaveConfig ={        EUSCI_B_SPI_MSB_FIRST,                          // MSB First        EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,  // Phase        EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH,     // Normal Polarity        EUSCI_B_SPI_3PIN                               // 3wire mode};
We utilize the following code to enable
/* Selecting P1.1 P1.2 and P1.3 in SPI mode */    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,            GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);    /* Initialize slave to MSB first, inactive high clock polarity and     * 3 wire SPI */    SPI_initSlave(EUSCI_B0_BASE, &spiSlaveConfig);    /* Enable the SPI module */    SPI_enableModule(EUSCI_B0_BASE);
The SPI_initSlave is defined here
From Driverlib manual
Add the following code to enable the SPI interrupt
/* Enable Receive interrupt */    SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT);    Interrupt_enableSleepOnIsrExit();    Interrupt_enableInterrupt(INT_EUSCIB0);
The complete code is attached
/* DriverLib Includes */#include <ti/devices/msp432p4xx/driverlib/driverlib.h>/* Statics */static volatile uint8_t transmitData = 0x01, receiveData = 0x00;/* SPI Slave Configuration Parameter */const eUSCI_SPI_SlaveConfig spiSlaveConfig ={        EUSCI_B_SPI_MSB_FIRST,                          // MSB First        EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,  // Phase        EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH,     // Normal Polarity        EUSCI_B_SPI_3PIN                               // 3wire mode};int main(void){    /* Stop watchdog timer */    WDT_A_holdTimer();    /* Selecting P1.1 P1.2 and P1.3 in SPI mode */    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,            GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);    /* Initialize slave to MSB first, inactive high clock polarity and     * 3 wire SPI */    SPI_initSlave(EUSCI_B0_BASE, &spiSlaveConfig);    /* Enable the SPI module */    SPI_enableModule(EUSCI_B0_BASE);    /* Enable Receive interrupt */    SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT);    Interrupt_enableSleepOnIsrExit();    Interrupt_enableInterrupt(INT_EUSCIB0);    Interrupt_enableMaster();    PCM_gotoLPM0();}//******************************************************************************////This is the EUSCI_B0 interrupt vector service routine.////******************************************************************************void EUSCIB0_IRQHandler(void){    uint32_t status;    status = SPI_getEnabledInterruptStatus(EUSCI_B0_BASE);    SPI_clearInterruptFlag(EUSCI_B0_BASE, status);    if(status & EUSCI_B_SPI_RECEIVE_INTERRUPT)    {        /* USCI_B0 TX buffer ready? */        while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));        //Receive data from master        receiveData = SPI_receiveData(EUSCI_B0_BASE);        SPI_transmitData(EUSCI_B0_BASE, receiveData);//echo data back    }}Task 4: Connect two boards via SPI
In this task, we will connect two boards together via SPI master and slave.
  • We need to connect pins GND, P1.5 (UCB0CLK), P1.6 (UCB0SIMO), and P1.7 (UCB0SOMI) from one board (SPI master) to another (SPI slave)
  • The connect photo like this

  • Test the code in Task2 and Task3 for the SPI master and SPI slave. Using the watch data and breakpoint to check the echoed data (RXData) is the same as the transmitted data.
  • Replace the code “MAP_SPI_transmitData(EUSCI_B0_BASE, ‘a’);” in the SPI master interrupt routine by the following code
MAP_SPI_transmitData(EUSCI_B0_BASE, ++TXData);
  • Replace the code “SPI_transmitData(EUSCI_B0_BASE, receiveData);” by the following code in SPI slave
SPI_transmitData(EUSCI_B0_BASE, transmitData++);
  • Check the transmitData value

The complete SPI master code with Uart is attached
/* DriverLib Includes */#include <ti/devices/msp432p4xx/driverlib/driverlib.h>/* Standard Includes */#include <stdint.h>#include <stdbool.h>/* Statics */static volatile uint8_t RXData = 0;static uint8_t TXData = 0;//![Simple SPI Config]/* SPI Master Configuration Parameter */const eUSCI_SPI_MasterConfig spiMasterConfig ={        EUSCI_B_SPI_CLOCKSOURCE_SMCLK,             // SMCLK Clock Source        12000000,                                   // SMCLK = DCO = 3MHZ        500000,                                    // SPICLK = 500khz        EUSCI_B_SPI_MSB_FIRST,                     // MSB First        EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,    // Phase        EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH, // High polarity        EUSCI_B_SPI_3PIN                           // 3Wire SPI Mode};//![Simple SPI Config]/* 115200*/const eUSCI_UART_Config uartConfig ={        EUSCI_A_UART_CLOCKSOURCE_SMCLK,          // SMCLK Clock Source        6,                                     // BRDIV = 6        8,                                       // UCxBRF = 8        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};/* 9600const 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};*/static volatile uint32_t mclk, smclk;int main(void){    /* Halting WDT  */    WDT_A_holdTimer();        /* Setting DCO to 12MHz */    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12);    mclk = CS_getMCLK();    smclk = CS_getSMCLK();        /* Selecting P1.2 and P1.3 in UART mode */    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,            GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);        /* Configuring UART Module */    MAP_UART_initModule(EUSCI_A0_BASE, &uartConfig);    /* Enable UART module */    MAP_UART_enableModule(EUSCI_A0_BASE);    /* Selecting P1.5 P1.6 and P1.7 in SPI mode */    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,            GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);    /* Configuring SPI in 3wire master mode */    MAP_SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig);    /* Enable SPI module */    MAP_SPI_enableModule(EUSCI_B0_BASE);    /* Enabling UART interrupts */    MAP_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);    MAP_Interrupt_enableInterrupt(INT_EUSCIA0);    /* Enabling SPI interrupts */    MAP_SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT);    MAP_Interrupt_enableInterrupt(INT_EUSCIB0);        MAP_Interrupt_enableSleepOnIsrExit();    MAP_Interrupt_enableMaster();                   /*Test UART transmit*/    MAP_UART_transmitData(EUSCI_A0_BASE, 'a');    /* Polling to see if the TX buffer is ready */    while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT)));    TXData = 2;    /* Transmitting data to slave */    MAP_SPI_transmitData(EUSCI_B0_BASE, TXData);    while(1)    {        MAP_PCM_gotoLPM0();    }}//******************************************************************************////This is the EUSCI_B0 interrupt vector service routine.////******************************************************************************void EUSCIB0_IRQHandler(void){    uint32_t status = MAP_SPI_getEnabledInterruptStatus(EUSCI_B0_BASE);    uint32_t jj;    MAP_SPI_clearInterruptFlag(EUSCI_B0_BASE, status);    if(status & EUSCI_B_SPI_RECEIVE_INTERRUPT)    {        /* USCI_B0 TX buffer ready? */        while (!(MAP_SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));        RXData = MAP_SPI_receiveData(EUSCI_B0_BASE);        /* Send the next data packet */        //MAP_SPI_transmitData(EUSCI_B0_BASE, ++TXData);        MAP_SPI_transmitData(EUSCI_B0_BASE, 'a');        /* Delay between transmissions for slave to process information */        for(jj=50;jj<50;jj++);    }}/* 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));    }}

使用特权

评论回复

相关帖子

沙发
manufact| | 2019-12-23 18:18 | 只看该作者
感谢楼主分享资料

使用特权

评论回复
板凳
monitoring| | 2019-12-29 10:44 | 只看该作者
感谢楼主的分享

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:欢迎进入【TI DSP 论坛】 & 【DSP 技术】           TI忠诚粉丝!

935

主题

26376

帖子

588

粉丝