2024-01-05 02:27 AM
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:
Memory Address Transmission:
Data Serialization:
STM32H745 Implementation:
Endianness Issues:
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
2024-01-05 06:43 AM
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.
2024-01-07 11:34 PM
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.