cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Memory Mapping Address and Data from GUI to STM32H745 over USB

dplogiic
Associate II

Hello forum members,

I am working on a project where I need to establish communication between a GUI and an STM32H745 microcontroller over USB. Specifically, I want to send a memory mapping address along with corresponding data from the GUI to the STM32H745. The STM32H745 will then use this information to update variables in its memory space.

I am looking for guidance on the best practices and considerations for implementing this communication. Here are some specific questions:

  1. Memory Address Transmission:

    • How can I safely transmit a memory mapping address from the GUI to the STM32H745 over USB?
    • Are there any security concerns or best practices that I should be aware of when sending memory addresses?
  2. Data Serialization:

    • What is the recommended method for serializing the memory address and data before transmission over USB?
    • Are there existing protocols or libraries that can assist in this serialization process?
  3. STM32H745 Implementation:

    • On the STM32H745 side, how can I efficiently receive and interpret the transmitted memory address and data?
    • What precautions should I take to ensure the STM32H745 can safely update variables based on external input?
  4. Endianness Issues:

    • How should I handle endianness considerations when transmitting and receiving multi-byte data between the GUI and the STM32H745?

I would appreciate any insights, code snippets, or recommended resources that could help me navigate this communication task. Thank you in advance for your assistance!

Best regards, 

Dp

2 REPLIES 2
Sebastiaan
Senior

Hi Dplogiic,

If you enable the USB_OTG_FS peripheral and try to activate the USB_DEVICE middleware in stm32CubeMx, you'll see that only a limited amount of device classes are available. Human Interface Device is one of them, but I haven't used that so I can't say how useful it is.

If you're looking towards the easiest approach, you can just use a Communication Device Class (CDC), which works as a serial port between your device and PC. You'll probably need to come up with a custom protocol on top of the serial layer, depending on your needs (would the data be fixed-size or variable size? write-only or read-write? etc). For example, Modbus RTU is a protocol that runs over serial, works with addressing, and might support everything you want. You can find some modbus RTU examples for stm32. If modbus is too complex or insufficient, you can design your own protocol.

About endianness, good to think about it upfront, but typically that's part of the protocol you're designing. For example, it seems that Modbus uses big-endian. In general, networks use big-endian.

dplogiic
Associate II

Hi Sebastiaan,

Thanks for your reply. I used USB_OTG_FS with CDC class. The data size be fixed and I want both read-write (Transmit- receive) data.