element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Experimenting with Gesture Sensors
  • Challenges & Projects
  • Design Challenges
  • Experimenting with Gesture Sensors
  • More
  • Cancel
Experimenting with Gesture Sensors
Forum Establishing serial communication over UART instead of USB in MAX25405 EVKIT
  • Challenge Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Experimenting with Gesture Sensors requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 89 replies
  • Subscribers 41 subscribers
  • Views 9088 views
  • Users 0 members are here
  • MAX25405
  • gesture sensors
  • maxim integrated
  • uart
  • max32620fthr
Related

Establishing serial communication over UART instead of USB in MAX25405 EVKIT

rsjawale24
rsjawale24 over 2 years ago

The MAX25405EVKIT comes with a MAX32620FTHR board which is preprogrammed with custom binary file for the gesture recognition. The application note at Maxim Gesture Sensor EVKit Serial API (maximintegrated.com)

mentions "The serial interface can be implemented over the Universal Serial Bus (USB) virtual serial port or over a Universal Asynchronous Receiver-Transmitter (UART). The EV kit is shipped configured to use the USB serial port to work with the EV kit PC Graphical user Interface (GUI). If a UART serial interface is desired, custom firmware in binary format is available."

Upon researching more, I found the firmware_framework code that contains the code for gesture recognition compiled using mbed compiler.

The readme file says that a file called interface.h and interface.c define the communication protocol. When I open the interface.c file, I can see a comment in the code that says Option to implement serial API over UART instead of USB but there is only a MACRO set as #define macro_name 0 

I tried to change the 0 to 1 and compile the code, however, it does not compile successfully. The USBDevice library shows some error while compiling. 

Did anyone try to change the serial API over UART instead of USB? Was it successful?  

EDIT: I have successfully compiled the code for UART. However, I'll do some experiments and write introductory blogs before I re-program the MAX32620FTHR board with my firmware. 

  • Sign in to reply
  • Cancel

Top Replies

  • misaz
    misaz over 2 years ago in reply to misaz +4
    Today I found root cause of the issue. Issue is caused by invalid assembly code generated by modern ARM compiler. With older GCC compiler it works because it handle undefined behaviour used in code differently…
  • misaz
    misaz over 2 years ago +3
    I am curious how did you successfully compiled non-changed code? I started working with latest mbed-os but I was unable to compile it (missing toolchain) no matter of USE_UART_INTERFACE setting. Later…
  • BigG
    BigG over 2 years ago in reply to rsjawale24 +3
    I've create a very basic stripped down library based on the firmware framework using the latest MbedOS 6.16. github.com/.../Max25x05_MbedOS6 All it is doing is getting the raw pixel data. It is doing…
Parents
  • rsjawale24
    rsjawale24 over 2 years ago

    So I'm facing another problem now.

    As long as I send commands like ver and ping, it works fine. But as soon as I send poll command, I get results and then it gets stuck there. It does not respond to any commands. Not sure why this is happening.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 2 years ago in reply to rsjawale24

    I've create a very basic stripped down library based on the firmware framework using the latest MbedOS 6.16.

    github.com/.../Max25x05_MbedOS6

    All it is doing is getting the raw pixel data. It is doing none of the manipulation routines as yet.

    It seems to provide data and does not lock up using USBserial - well OK, I only let the program run for about 20 seconds. You should be able to change USBSerial and use RX/TX pins.

    Please let me know if you spot any errors, or have any problems, and you are free to recommend changes.

    At the moment, the only thing that is puzzling me is the configuration setting used in the Firmware Framework for MAIN CONFIGURATION 2 (0x2). Here the value is set to 0x02 and this does not correspond with the documentation.

    Maybe someone has an answer.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • rsjawale24
    rsjawale24 over 2 years ago in reply to BigG

    Thanks, I'll check this. But the gesture algorithm is quite complex, I guess. Here from the raw pixel data it would be difficult to identify the gestures, or maybe a simple gesture sensing algorithm can be devised by reading the raw sensor data. 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 2 years ago in reply to rsjawale24

    Yep, it is quite complex but I'm trying to simplify the code so that it is easier to understand, and also hopefully, to make sure it does not lock up. At least for now, I know that the sensor can be read and the raw values can be printed without glitching.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • misaz
    misaz over 2 years ago in reply to BigG

    Almost everything can be done without glitching on MCU clocked at 96 MHz (96 000 000 clock cylces per second) with 256 KiB (262 144 bytes) RAM. There is some more significant issue with the firmware. I think it is easier to fix Maxim firmware in this case. I packed up MAX32620FTHR this weak but I forgot to pack up PICO board for debugging, so I will debug it later this weekend.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • rsjawale24
    rsjawale24 over 2 years ago in reply to BigG

    Yes, the issue is not with the hardware so it should not lock up the program while reading. The problem lies in the firmware code provided by Maxim. Which currently, I'm unable to determine. 

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 2 years ago in reply to misaz

    misaz rsjawale24 Oops maybe a poor choice of words used... I meant glitching in the broadest sense (dictionary def: suffer a sudden malfunction or fault) and took it as software/firmware related.

    In my experience you need a debugger to catch these errors and when you're not the author of the code it becomes rather difficult to work out the problem. As such, I have found my personal preference, as it works for me, is to recreate or repack the code function by function to fathom out what's going on.

    The code is certainly a little messy for my liking. Now that I've spent a bit of time on this, I have determined (so far) that there are at least 6 pixel arrays (each size 60 of integer or float data type) which are storing pixel data plus the different data structures. So yes it uses a fair bit of memory.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • misaz
    misaz over 2 years ago in reply to BigG

    I understand. I am not good in english so maybe I misunderstand your previous post.

    Repacking and simplifing project is good idea, but I will still try to debug code rather. My theory is that it crashes to some HardFault handler so it should not be so hard to debug. But who knows? I did not try it yet.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • rsjawale24
    rsjawale24 over 2 years ago in reply to BigG

    I'm not very good at coding..all I can do is write simple programs and understand codes. But when it comes to writing codes for such complex devices, I'm not very good at that. I will try debugging..I have ordered a Maxim Pico and I should recieve it soon. However, I don't know how to debug.

    Also while compiling the code, I noticed there were tons of warnings being generated. Maybe some of the warnings are critical and are affecting the firmware working.

    Its really great that you're working on your own code!

    Also another thing to note which I just remembered the maxim firmware only locks up when you send the poll command, it does not lock up for other commands no matter how many times you send them.

    So this could be some kind of data overloading not sure. Let's try debugging. I'll need some help with that though

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 2 years ago in reply to rsjawale24

    Don't let the quantity of code put you off. The algorithms are actually fairly straightforward. It's just a little messy that's all, probably because the code has not been worked on and refined.

    So, basically the code captures an array of data from the sensor (using either SPI or I2C), then it averages things out for you using a sort of moving average (as in averages out 3 data arrays) and then it does some filtering of the data to extract out background noise using another 2 data arrays and a min and max value, so that it can detect the gesture.

    It then has some code that determines if it detects movement in progress or the movement has stopped (I haven't figured out how it does this part). It also prints out the data.

    The user command part is just for the windows GUI software.

    As such, regardless of algorithm & user command, you are still left with 6 rows of data containing 10 values each. You will still have to use that data to determine the gesture.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • misaz
    misaz over 2 years ago in reply to rsjawale24

    I am getting near... Here is stack trace of location in which our firmware stuck after executing poll command. mbed_halt_system has infinite loop in which program stuck. Stuck is consequence of some hard fault.

    image

    I found quick (but not reliable answer): Change compiler. If you use gcc bundled in Debian instead ARM compiler which I recommended, then It generates more compact image which works Smiley But I will still dig into it and try find solution working with any compiler if possible.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • misaz
    misaz over 2 years ago in reply to misaz

    Today I found root cause of the issue. Issue is caused by invalid assembly code generated by modern ARM compiler. With older GCC compiler it works because it handle undefined behaviour used in code differently. I will write (long) blog with more details describing what exactly happended on Cortex-M4 core including all details about my analysis, listings of faulty assembly code and (lot of) details about debugging procedure which I applied to finding root cause of issue.

    TLDR solution for our problem is following.

    1. Open cmd.cpp
    2. Go to function cmd_poll at line 269
    3. Add return CMD_ACK; to the end of the function
    4. Recompile, enter bootloader, drag and drop new firmware and MCU will not crash after poll command anymore.

    The missing return statement cost me about 7 hours of debugging....

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • misaz
    misaz over 2 years ago in reply to misaz

    Today I found root cause of the issue. Issue is caused by invalid assembly code generated by modern ARM compiler. With older GCC compiler it works because it handle undefined behaviour used in code differently. I will write (long) blog with more details describing what exactly happended on Cortex-M4 core including all details about my analysis, listings of faulty assembly code and (lot of) details about debugging procedure which I applied to finding root cause of issue.

    TLDR solution for our problem is following.

    1. Open cmd.cpp
    2. Go to function cmd_poll at line 269
    3. Add return CMD_ACK; to the end of the function
    4. Recompile, enter bootloader, drag and drop new firmware and MCU will not crash after poll command anymore.

    The missing return statement cost me about 7 hours of debugging....

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • Cancel
Children
  • rsjawale24
    rsjawale24 over 2 years ago in reply to misaz

    I was getting error that function is not void so it should return something. I just put return 0 there and it compiled successfully. However return 0 will only return 0 after successful execution. How come I didn't think of this!!

    Thanks for the help. I'll try it asap

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • misaz
    misaz over 2 years ago in reply to rsjawale24

    This function should return 0 allways.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • rsjawale24
    rsjawale24 over 2 years ago in reply to misaz

    Then just adding return 0 should also work!!

    I'll try it and will post her

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 2 years ago in reply to misaz

    Wow, great spot (re Add return CMD_ACK; )

    It's worth noting that the poll command is lacking the actual gesture result, as you see in the default demo binary.

    In the poll command all it provides is a placeholder (gesResult.int_placeholder,)

    Also, if you look in gesture_lib.h you will see the gestureEvent enum only provides a template:

    /*
    * Enumerate gesture events here
    */
    typedef enum {
        GEST_NONE,
        GEST_PLACEHOLDER
    } GestureEvent;

    No doubt there is a bunch of code in that demo binary to adds in all the gestures.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • misaz
    misaz over 2 years ago in reply to BigG

    As far I did not fix any code logic. I just ensured that code do not crash.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 2 years ago in reply to misaz

    As far as I can work out I think it requires a major piece of work to get the MCU to recognise different gestures.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • rsjawale24
    rsjawale24 over 2 years ago in reply to BigG

    The poll command was returning all 0'z and then crashing. It seems now it won't crash but the result will still be 0's if there is logic problem. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 2 years ago in reply to rsjawale24

    Yes that's correct. So at least the crash has been sorted but some way to go to now get real answers.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • dougw
    dougw over 2 years ago in reply to misaz

    great work digging out the root cause

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • misaz
    misaz over 2 years ago in reply to misaz

    If someone is interested, today I published blog with detials about debugging:  Blog #7: Debugging Maxim’s Firmware Framework Crash

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube