SLAU857A May   2021  – July 2021 MSP430FR2476 , MSP430FR2512 , MSP430FR2522 , MSP430FR2532 , MSP430FR2533 , MSP430FR2632 , MSP430FR2633 , MSP430FR2672 , MSP430FR2673 , MSP430FR2675 , MSP430FR2676

 

  1.   1
  2.   2
    1.     3
    2.     4
  3.   5
    1.     6
    2.     7
    3.     8
  4.   9
    1.     10
      1.      11
      2.      12
      3.      13
    2.     14
    3.     15
  5.   16
    1.     17
      1.      18
      2.      19
        1.       20
        2.       21
        3.       22
      3.      23
    2.     24
      1.      25
      2.      26
  6.   27
    1.     28
      1.      29
      2.      30
      3.      31
      4.      32
      5.      33
    2.     34
      1.      35
      2.      36
      3.      37
    3.     38
    4.     39
      1.      40
      2.      41
      3.      42
      4.      43
      5.      44
    5.     45
    6.     46
      1.      47
      2.      48
      3.      49
      4.      50
      5.      51
  7.   52
    1.     53
    2.     54
    3.     55
    4.     56
    5.     57
  8.   58
  9.   59

Customization of Communication Functions

It is recommended to use the provided UART and I2C library functions for development to communicate with the host MCU. First of all, the default code generated by the GUI completes the I/O configuration and clock configuration of UART (eUSCI_A0) and I2C (eUSCI_B0) in the BSP_configureMCU() function. Therefore, it is only necessary to configure the communication module and write the communication protocol. If you need to modify the communication interface, check the datasheet to see if you need to modify the SYSCFG3 register to redirect the communication port.

UART-based communication development:

  • Communication Interface configuration: NONE
  • Clock configuration: BSP_configureMCU()
  • IO configuration: BSP_configureMCU()
  • UART peripheral configuration and interrupt usage: Driverlib UART loopback

There are two schemes for I2C-based communication development for reference. The scheme occupies less code, and the second scheme saves development time.

Option one:

Option two:

  • User Guide:I2C Slave driver user guide
  • Communication Interface configuration: NONE
  • Clock configuration: BSP_configureMCU()
  • IO configuration: BSP_configureMCU()
  • I2C peripheral configuration and interrupt usage: The code under the REGISTER_I2C configuration includes I2C peripheral configuration and interrupt usage. The user only needs to analyze the 3-byte transmit and receive Buffer. The operation steps are as follows:
  1. Modify the CAPT_I2CRegisterReceiveHandler() function in captivate->COMM->CAPT_Interface.c. This function is called when the stop signal or restart signal are generated after the I2C write operation is completed. As shown in Figure 5-16, delete other codes and add custom frame processing functions.
    GUID-20210517-CA0I-6FM7-W6C3-0CJHL3NWLFZW-low.pngFigure 5-16 CAPT_I2CRegisterReceiveHandler() Function Modification
  2. Write a custom frame processing function. As shown in Figure 5-17, the MSP430 MCU reads a byte sent by the host, then modify the first byte of the data segment in the Buffer, and then wait for the host to actively read the byte. It should be noted that I2C sending and receiving share a 32-byte buffer, and the whole process does not reset it. In addition, the receiving/sending data segment in the buffer has an offset of 3 bytes. Therefore, the fourth byte of the Buffer corresponds to the first byte of the received/sent data.
    GUID-20210517-CA0I-MBZ9-SDV0-JRF6KRRHDBRZ-low.pngFigure 5-17 Frame Processing Function
  3. Build the overall code as shown in Figure 5-18. The additional functions included are:
    • Panel_Init(): System custom initialization, register the sensor callback function.
    • BTNEventHandler(): The processing function that defines the state of the sensor.
    GUID-20210517-CA0I-Q3BD-DFCB-SHHVQZN6H1NV-low.pngFigure 5-18 Diagram of the Overall Code

Table 5-13 shows the information related to the custom communication function.

Table 5-13 Customized Communication
NumberObjectModification methodComment
1 eUSCI_A0/eUSCI_B0 port Modify the pin definition in Captivate_app->CAPT_BSP.C->BSP_configureMCU() Select other communication peripherals, need to modify the initialization of the peripherals.
2 IRQ signal of I2C Modify the macro definition of IRQ pin in Captivate->COMM->CAPT_CommConfig.h

Modify the macro definition of IRQ pin action in Captivate->COMM->I2CSlave.h

This pin is used to remind the host computer of a touch event.
3 Whether the CapTIvate module enables the Timer peripheral Modify the assignment of FUNCTIONTIMER__ENABLE in CapTIvate->COMM->FunctionTimer.h Used for timeout function in I2C communication.
5 Timeout function of I2C communication Modify the assignment of I2CSLAVE__TIMEOUT_ENABLE in Captivate->COMM->I2CSlave_Definitions.h

Modify the assignment of I2CSLAVE__TXFR_TIMEOUT_CYCLES in Captivate->COMM->I2CSlave_Definitions.h

By default, the host resets I2C if a single frame transmission exceeds 8 ms.
5 Modify I2C address Modify I2CSLAVE__ADDRES in CapTIvate->COMM->I2CSlave_Definitions.h