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.

MSPM0G3519: GPIO ISR-based parallel bit capture from ADAM I/O modules producing corrupted/misaligned data

Part Number: MSPM0G3519

Hello,

I'm working on a project using the MSPM0G3519 LaunchPad to read parallel digital outputs from Advantech ADAM I/O modules. I'd appreciate guidance on whether my current approach is viable or if I should be using a different peripheral strategy.

System Overview

  • Source: ADAM digital I/O modules (parallel bit outputs)
  • Host interface: UART to a PC terminal
  • Goal: When the host PC sends a command byte to the ADAM module, capture the resulting bit pattern on the MSPM0's GPIO pins and echo it back over UART.

Current Implementation

  • Each ADAM output bit is wired to a separate MSPM0 GPIO pin.
  • Each of those GPIOs is configured with a GPIO interrupt on both rising and falling edges.
  • Inside the ISR I update a byte variable bit-by-bit and then transmit the assembled byte over UART.
  • All GPIO ports are configured as pullup resistors.

Problem

The received byte does not match the transmitted command. Examples:

  • Sending 0x75 → MSPM0 reports 0xAA
  • Sending 0x01 → MSPM0 reports 0xFF

Wiring has been verified multiple times, so I believe this is a timing / sampling issue rather than a connection problem. My suspicion is that using per-bit edge ISRs introduces enough jitter and ordering ambiguity that bits are being latched at the wrong times relative to one another.

Questions

  1. Is per-pin edge-triggered ISR the wrong approach for parallel bit capture on the MSPM0G3519? 
  2. Does the MSPM0G3519 have a recommended peripheral (Timer Capture, DMA-triggered GPIO snapshot, or similar) for latching multiple GPIO bits simultaneously on an external event?
  3. Are there example projects or app notes for parallel data ingest on MSPM0 that you can point me to?
  4. Any known ISR latency figures I should account for when sampling asynchronous parallel signals?

Thank you

  • Hi,
    Before answering your questions, I need you to clarify a few details.
    First, what is the output mode of the ADAM module? Does it latch the output and hold the value after receiving a command, or is it a pulse output that only stays valid for a short time before returning to its default state?
    Second, regarding the test results you provided, is the result always 0xAA every time you send 0x75, or does the result vary between tests?
    Thanks.
  • First Question: 

    According to the manual, the ADAM-4050 output architecture is described as follows:

    "The outputs are open-collector transistor switches that you can control from the host computer. You can also use the switches to control solid-state relays, which can be applied to equipment such as heaters and pumps. The host computer can use the module's digital inputs to determine the states of limit, safety switches, and remote digital signals."

    Digital Input:

    • Wet contact:
      • Logic level 0: +1 V max.
      • Logic level 1: +3.5 ~ 30 V
    • Dry contact:
      • Logic level 1: Open
      • Logic level 0: Close to ground

    Digital Output:

    • Open collector to 30 V, 30 mA max. load

      So it seems like once a command is received, the output holds its state and does not revert to a default value until a new command is sent. It is not a pulse output.

    Second Question:

    I noticed that the test results are repeated every time I send a serial command (e.g., 0x75) to the terminal. To investigate further, I used a GUI interface that allows me to send multiple commands at once.

    Sent to the computer:

    Hex Binary
    0x75 01110100
    0x24 00100100
    0x55 01010101
    0x04 00000100
    0x15 00010101

    Received back:

    Hex Binary
    0xAA 10101001
    0xEF 11101111
    0xBB 10111011
    0xFF 11111111
    0xFB 11111011
  • Hi,
    Thank you for the information provided. Based on the symptoms you described, I believe the most likely root cause lies in a fundamental limitation of the edge-triggered ISR approach: an ISR only fires when a pin changes state. If a pin's state does not change between the previous command and the current one, no edge is generated, and that bit's value will never be updated — it will simply retain whatever initial value was set in your code.
    I need to confirm two things. First, what is the default state of the ADAM module's outputs after power-on, before any command is received — are they all low, all high, or something else? Second, does your code clear the result variable before each new read?
    With that said, I recommend changing the read logic as follows: after the UART finishes receiving a command and after an appropriate settling delay, perform a single read of the GPIO DIN register. This ensures all 8 bits are captured atomically at the same moment, completely eliminating the risk of missed edges. For reference, please consult the TRM (SLAU846D) and application note SDAA286. You can start from SLAU846D p.773slau846d.p773, and SDAA286 p.12 contains an example you can refer to.sdaa286.p12
    Thanks.
  • You should probably read *every* bit anytime one triggers the interrupt.