MCUXpresso SDK Documentation

a-format_polling_transfer

a-format_polling_transfer#

Overview#

The a-format_polling example shows how to use flexio A-format driver in polling way:

In this example, a flexio simulated A-format connect to the encoder through RS-485, the board will send requests to and receive responses from the board.

Supported Boards#

i.MXRT1180-EVK
Hardware requirements
  • Micro USB cable

  • MIMXRT1180-EVK board

  • J-Link Debug Probe

  • 5V power supply

  • Personal Computer

  • RS-485 adapter board

Board settings

This example requires connecting between FlexIO2 pins and RS-485 adapter board which is connected to the encoder.

  • FLEXIO_A_FORMAT_TX_PIN(J41-2) -> RX pin of RS-485

  • FLEXIO_A_FORMAT_RX_PIN(J41-4) -> TX pin of RS-485

  • FLEXIO_A_FORMAT_DR_PIN(J41-6) -> D/R pin of RS-485

  • 3.3V pin(J45-8) -> 3.3V pin of RS-485

  • GND pin(J45-12) -> GND pin of RS-485

  • 5.0V pin(J45-16) -> 5.0V pin of encoder

  • GND pin(J45-14) -> GND pin of encoder

  • A pin of RS-485 -> SD+ pin of encoder

  • B pin of RS-485 -> SD- pin of encoder

Prepare the Demo
  1. Connect 5V power supply and J-Link Debug Probe to the board, switch SW1 to power on the board.

  2. Connect a micro USB cable between the host PC and the J53 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you can see the similar information from the terminal as below.

Encoder A-format example
Encoder ID: 5946590
Multi-turn data: 64474, single-turn data: 147617
[0.10s] Encoder ID: 0x5ABCDE
         Multi-turn data: 64474, single-turn data: 147617
         Temperature: 45.000000
[0.20s] Encoder ID: 0x5ABCDE
         Multi-turn data: 64474, single-turn data: 147617
         Temperature: 44.000000
FRDM-MIMXRT1186
Hardware requirements
  • USB Type-C cable

  • FRDM-IMXRT1186 board

  • 5V power supply

  • Personal Computer

  • FRDM-LVPMSM-FA board

  • 4-pin Mini DIN power supply

Board settings

This example requires connecting between FRDM-IMXRT1186 board and FRDM-LVPMSM-FA board.

  • Short J4-1 and J4-2 on the FRDM-IMXRT1186 board

  • Short J300-1 and J300-2 on the FRDM-LVPMSM-FA board

  • J72 and J73 jumpers are left unconnected on the FRDM-LVPMSM-FA board

  • FRDM-LVPMSM-FA SW90[1-4] = 0111

  • FRDM-LVPMSM-FA SW30[1-4] = 0100

  • FRDM-LVPMSM-FA J70-1 -> 5.0V pin of encoder

  • FRDM-LVPMSM-FA J70-6 -> GND pin of encoder

  • FRDM-LVPMSM-FA J70-4 -> SD+ pin of encoder

  • FRDM-LVPMSM-FA J70-9 -> SD- pin of encoder

Prepare the Demo
  1. Connect a USB Type-C cable between the PC host and the OpenSDA USB port on the FRDM-IMXRT1186 board.

  2. Connect 5V power supply, then switch SW5 to power on the FRDM-IMXRT1186 board.

  3. Connect 4-pin Mini DIN power supply to J10 on the FRDM-LVPMSM-FA board.

  4. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  5. Download the program to the target board.

  6. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you can see the similar information from the terminal as below.

Encoder A-format example
FlexIO Root Clock is 80 MHz

******************** 1 to 1 mode (Only one encoder connects to the board) ********************
****************
* Test case  1 *
****************
> Set the encoder address to 3 ==> successful
****************
* Test case  2 *
****************
> Set the encoder ID to 0x030201 ==> successful
****************
* Test case  3 *
****************
> Get the encoder ID ==> 0x030201 (successful)

......

******************** Running the loop test ********************
[0.10s] Multi-turn data: 64478, single-turn data: 715574
       Temperature: 43.000000

[0.20s] Multi-turn data: 64478, single-turn data: 726567
       Temperature: 43.000000
IMX943-EVK
Hardware requirements
  • Micro USB cable

  • IMX943-EVK board

  • J-Link Debug Probe

  • 12V~20V power supply

  • Personal Computer

  • RS-485 adapter board

Board settings

This example requires connecting between FlexIO1 pins and RS-485 adapter board which is connected to the encoder.

  • FLEXIO_A_FORMAT_DR_PIN(J48-10) -> D/R pin of RS-485

  • FLEXIO_A_FORMAT_TX_PIN(J48-9) -> RX pin of RS-485

  • FLEXIO_A_FORMAT_RX_PIN(J48-11) -> TX pin of RS-485

  • 3.3V pin(J49-8) -> 3.3V pin of RS-485

  • GND pin(J49-12) -> GND pin of RS-485

  • 5.0V pin(J49-10) -> 5.0V pin of encoder

  • GND pin(J49-14) -> GND pin of encoder

  • A pin of RS-485 -> SD+ pin of encoder

  • B pin of RS-485 -> SD- pin of encoder

Please note this application can’t support running with Linux BSP!
Note

Please run the application in Low Power boot mode (without Linux BSP). The IP module resource of the application is also used by Linux BSP. Or, run with Single Boot mode by changing Linux BSP to avoid resource conflict. Tips: After you insert the USB2COM, a new USBCOM will be found. The function output in new USBCOM.

Prepare the Demo
  1. Connect 12V~20V power supply and J-Link Debug Probe to the board, switch SW301 to power on the board.

  2. Connect a micro USB cable between the host PC and the J1401 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you can see the similar information from the terminal as below.

Encoder A-format example
Encoder ID: 5946590
Multi-turn data: 64474, single-turn data: 147617
[0.10s] Encoder ID: 0x5ABCDE
         Multi-turn data: 64474, single-turn data: 147617
         Temperature: 45.000000
[0.20s] Encoder ID: 0x5ABCDE
         Multi-turn data: 64474, single-turn data: 147617
         Temperature: 44.000000
FRDM-MCXA266
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXA266 board

  • Personal Computer

  • A-format encoder

  • RS-485 transceiver

Board settings

This example uses FlexIO0 to simulate the A-format master and communicates with the encoder through an RS-485 transceiver. Connect the encoder to the FRDM-MCXA366 board as below:

The A-format signals are routed to the following FlexIO0 pins (MUX ALT6):

  • FLEXIO0_D16 (P2_8, pin 41) -> DR (direction / driver-enable)

  • FLEXIO0_D17 (P2_9, pin 42) -> TX (transmit data to the RS-485 transceiver)

  • FLEXIO0_D18 (P2_10, pin 43) -> RX (receive data from the RS-485 transceiver)

Wire the RS-485 transceiver to the encoder:

  • 5.0V -> 5.0V pin of encoder

  • GND -> GND pin of encoder

  • SD+ -> SD+ pin of encoder

  • SD- -> SD- pin of encoder

Prepare the Demo
  1. Connect a USB Type-C cable between the PC host and the MCU-Link USB port on the board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you can see the similar information from the terminal as below.

Encoder A-format example
FlexIO Root Clock is 90 MHz

******************** 1 to 1 mode (Only one encoder connects to the board) ********************
****************
* Test case  1 *
****************
> Set the encoder address to 3 ==> successful
****************
* Test case  2 *
****************
> Set the encoder ID to 0x030201 ==> successful
****************
* Test case  3 *
****************
> Get the encoder ID ==> 0x030201 (successful)

......

******************** Running the loop test ********************
[0.10s] Multi-turn data: 64478, single-turn data: 715574
       Temperature: 43.000000

[0.20s] Multi-turn data: 64478, single-turn data: 726567
       Temperature: 43.000000
FRDM-MCXA366
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXA366 board

  • Personal Computer

  • A-format encoder

  • RS-485 transceiver

Board settings

This example uses FlexIO0 to simulate the A-format master and communicates with the encoder through an RS-485 transceiver. Connect the encoder to the FRDM-MCXA366 board as below:

The A-format signals are routed to the following FlexIO0 pins (MUX ALT6):

  • FLEXIO0_D16 (P2_8, pin 41) -> DR (direction / driver-enable)

  • FLEXIO0_D17 (P2_9, pin 42) -> TX (transmit data to the RS-485 transceiver)

  • FLEXIO0_D18 (P2_10, pin 43) -> RX (receive data from the RS-485 transceiver)

Wire the RS-485 transceiver to the encoder:

  • 5.0V -> 5.0V pin of encoder

  • GND -> GND pin of encoder

  • SD+ -> SD+ pin of encoder

  • SD- -> SD- pin of encoder

Prepare the Demo
  1. Connect a USB Type-C cable between the PC host and the MCU-Link USB port on the board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you can see the similar information from the terminal as below.

Encoder A-format example
FlexIO Root Clock is 90 MHz

******************** 1 to 1 mode (Only one encoder connects to the board) ********************
****************
* Test case  1 *
****************
> Set the encoder address to 3 ==> successful
****************
* Test case  2 *
****************
> Set the encoder ID to 0x030201 ==> successful
****************
* Test case  3 *
****************
> Get the encoder ID ==> 0x030201 (successful)

......

******************** Running the loop test ********************
[0.10s] Multi-turn data: 64478, single-turn data: 715574
       Temperature: 43.000000

[0.20s] Multi-turn data: 64478, single-turn data: 726567
       Temperature: 43.000000