element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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
Join Experimenting with Gesture Sensors to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 89 replies
  • Subscribers 41 subscribers
  • Views 10339 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
  • BigG
    BigG over 2 years ago

    I was experimenting with the different options on the MAX32620FTHR board to print serial messages. I created some simple code to test behaviour using the latest MbedOS 6.16.

    I made life easier and also used a wrapper library, which you would need to import into your project: os.mbed.com/.../

    Here is the example code:

    /* mbedOS 6.16
     * Board: MAX32620FTHR
     * Copyright (c) C Gerrish
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include "mbed.h"
    #include "BufferedSerial.h"
    #include "SerialStream.h"
    #include "USBSerial.h"
    
    // Blinking rate in milliseconds
    #define BLINKING_RATE       1000ms
    
    #define UART_BAUD_RATE      115200
    
    BufferedSerial fthrUART(P3_1,P3_0, UART_BAUD_RATE);
    // This SerialStream is a wrapper for Stream.h to give you printf
    SerialStream<BufferedSerial> RXTX(fthrUART);
    
    // true here blocks until USB serial monitor opens
    // in Arduino you would use while(!Serial) for same effect
    USBSerial USB(true, 0x0b6a, 0x4360, 0x0001);
    
    int main()
    {
        // Initialise the digital pin LED1 as an output
        DigitalOut led(LED1);
    
        int cntr = 0;
    
        while (true) {
            led = !led;
            ThisThread::sleep_for(BLINKING_RATE);
            USB.printf("hello USB world %d\r\n", cntr);
            RXTX.printf("hello RXTX world %d\r\n", cntr);
            printf("hello DEBUG world %d\r\n", cntr);
            cntr++;
        }
    }
    

    The mbed_app.json file:

    {
        "target_overrides": {
            "*": {
                "platform.stdio-baud-rate": 115200,
                "platform.stdio-buffered-serial": 1
            }
        }
    }
    

    And here is a short video:

    You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image

    [Post EDIT]

    Looking at the original MAX25x05 gesture library again to see how the serial part could be adapted to OS6.16 I would say that you could use...

    the UnbufferedSerial API for when USE_UART_INTERFACE = 1 as this only provide putc etc.

    I've just realised that the above statement is not correct.

    In OS6.xx, it is not that simple to use putc anymore. In fact, I think the only way I could find is though the SerialStream wrapper. Not worth the effort, IMHO. If I had read the UnbufferedSerial API documentation more carefully then I would see that it only provides a write function. Sorry about that.

    and you could use BufferedSerial API for when USE_UART_INTERFACE = 0 as this provide buffered writes etc.

    Hope that helps.

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

    I was thinking about how we could minimise changes in the code, so here is one option that simplifies things.

    This code will either print to the debug/console UART pins (as defined in pinNames.h) or to UART pins of choice.

    #include "mbed.h"
    
    #define USE_UART_INTERFACE 1
    
    #if USE_UART_INTERFACE
        #define printf(f_, ...) fprintf((f_), __VA_ARGS__);
    #else
        #define printf(f_, ...) printf( __VA_ARGS__);
    #endif
    
    BufferedSerial otherUART(P3_1,P3_0,MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
    FILE* myTX = fdopen(&otherUART, "r+");
    
    // main() runs in its own thread in the OS
    int main()
    {
        printf(myTX,"Hello New World\r\n");
    
        while (true) {
    
        }
    }
    
    

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

    Are you still using your version of MbedOS?

    Just to say that I have managed to get the firmware working with the latest MbedOS 6.16 and have tested it using a Windows laptop with the Maxim GUI software. It all works. I'll post some guidance if you need it. Basically this is cleaner as you do not need to download the separate USBdevice or the MAX32620 libraries. All I had to do was amend a couple of lines in interface.cpp.

    So, basically I ignored the UART option as there really is no point using this option when the shield is attached to the MAX32620FTHR board, because you cannot readily get access to the GPIO's unless putting it on a breadboard or soldering wires.

    But, if I wanted to use UART in the latest MbedOS 6.16 I would then have to use with BufferedSerial or UnbufferedSerial API and then I would need to amend the code in CMD.cpp as, unlike USBSerial, these API's don't provide printf or getc functions.

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

    He want to do something different. By default firmware communicates with computer over virtual UART over USB. But he do not want this virtual UART. Rather he want real UART. He do not want to comunicate with board from computer but he want use Arduino instead. He correctly found macro which can switch firmware to use real instead of virtual UART but his communication do not work. I am currently out of home so I cant try his firmware but I will do this this weekend.

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

    Do you use any level shifter? What is your connection? Can you post some photo?

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

    I'm using the same version as misaz has used in his mbed CLI. 
    I'm using the git commitID 0fdfcf7350896a9c0b57c4a18237677abfe25f1a 

    I'm not sure which version it belongs to. But it is the only one that gives no error in compiling the firmware framework provided by Maxim.

    My aim is to get the gesture results over UART so that it can be sent to any general MCU like Arduino. 
    With the above-mentioned release of mbed, the code works fine for USB so it should work for UART as well as the basic structure of code remains same, only the path where data is sent changes from USB to UART.

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

    Hi! No, I'm not using any level shifter, I assumed that UART is using the standard logic levels. 

    Here's my connection diagram -

    image

    Baud rate for both the devices is 115200. 

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

    Do you have voltmeter (multimeter)? If yes, try disconnect wires and measure voltage on MAX32620 TX pin. It would be one of 1.8V or 3.3V. What Arduino do you use? ATMega based or some newer ARM Arduino? In case of standard 5V Arduino UNO this connection is dangerous. In case of newer ARM based Arduinos which are usualy powered by 3.3V this connection may be sufficient in case if you measure 3.3V on TX pin.

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

    Ah! I tried multiple arduinos. Uno, Micro and then MKR WAN 1300. Let me do the measurements on the pins. I had completely forgotten that MAX32620 has different voltages then the standard MCUs. I'm reading about 0.8V on the Tx pin of the MAX32620. I'll check the datasheet for the UART logic levels. 

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

    0.8V means pin in High Impedance so this pin is not the output (which TX should be). 0.8V (or any other different than 0V, 1.8V and 3.3V) you should measure on RX pin. On what pin do you measure voltage?

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

    I measured on Tx 0V and Rx 0.8V

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

    Interesting. RX is OK but TX should be in logical 1 when indle but your pin is in logical 0 state for some reason. Does the 0V remains after reset?

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

    Interesting. RX is OK but TX should be in logical 1 when indle but your pin is in logical 0 state for some reason. Does the 0V remains after reset?

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

    Yes Tx remains 0V after reset as well. I'll try some example firmware for UART to check if it works. 

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

    Ok. Currently I am out of ideas which can I provide without having access to real device.

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

    I flashed the board with the code provided by BigG now I read 1.3V on Rx (as written on the PCB of MCU) and 0V on Tx pin (as written on the MCU PCB). I think the interpretation of Tx and Rx could be different on Maxim boards. 

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

    Btw what pin exactly do you use as TX and RX? MAX32620 supports four UARTs. Do you use pins expossed on shield on JP5 or do you connect directly to some pinheader of FTHR board?

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

    No issues. I'll try some more methods to check the UART. Let me know if you succeed with this over the weekend. 

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

    The code in the framework has defined pins P3_0 and P3_1 as UART pins.  

    #if USE_UART_INTERFACE
    Serial *serial = new Serial(P3_1,P3_0,UART_BAUD_RATE);

    I'm using the same pins connecting wires directly to the pin headers of P3_1 and P3_0

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

    It is the same behaviour. 1.3V is the same as 0.8V. RX pin is input. MAX32620 set this pin as input which means that it do not connect this pin directly to GND (0V) or VDDIO(H) (1.8 or 3.3V depending on fimrware selection). Because pin is virtualy disconnected there theoreticaly is only voltage provided externaly like noise, inducted voltage from your body, signal from aliens and so on. Practicaly this voltage come also from implementation of digital logic.

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

    Yes. Pins 3.0 and 3.1 should be correct. These pins are also routed to shield to JP5.

    • 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