PC Communications :: One-way UART ASCII output

  1. Make sure the mComm_config.h file is properly configured.

     #define MCOMM_ENABLED
     #define MCOMM_TYPE                    MCOMM_UART_ONE_WAY
     #define MCOMM_UART_BAUDRATE           38400                       // (or) other valid baud rate option
    
     #define MCOMM_UART_1WAY_MODULE        MCOMM_UART_HARDWARE_MODULE  // (or) MCOMM_UART_SOFTWARE_IMPLEMENTATION
     
         // If MCOMM_UART_SOFTWARE_IMPLEMENTATION is chosen:
         #define MCOMM_UART_SOFT_TXPORT        PORTA
         #define MCOMM_UART_SOFT_TXTRIS        TRISA   
         #define MCOMM_UART_SOFT_TXPIN         5       // <-- The bit of the PORT/TRIS register
                                                       //     NOT the hardware pin on the device
    
     #define MCOMM_UART_1WAY_OUTPUT        MCOMM_UART_1WAY_DECIMAL     // (or) MCOMM_UART_1WAY_HEX        
     #define MCOMM_UART_1WAY_DELIMITER     ';'                         
    

    If you wish to use the PIC18F PIC24F One-Way GUI, force the mComm module to follow the GUI's packet structure by defining this value:

     #define MCOMM_UART_1WAY_OUT_GUIv1_1
    

    The following options will determine what values are output by the UART. Matrix output is not supported by the GUI but may be seen from a terminal window.

     #define MCOMM_UART_1WAY_OUT_STATE             // <-- If defined, outputs the state mask
     #define MCOMM_UART_1WAY_OUT_TOGGLE            // <-- If defined, outputs the toggle state mask
     #define MCOMM_UART_1WAY_OUT_SLIDER            // <-- If defined, outputs the slider output value
     #define MCOMM_UART_1WAY_OUT_MATRIX            // <-- If defined, outputs the matrix press coordinate
     #define MCOMM_UART_1WAY_OUT_READING           // <-- If defined, outputs the raw reading values
     #define MCOMM_UART_1WAY_OUT_BASELINE          // <-- If defined, outputs the sensor baseline values
    

    If you are using a processor with an APFCON register that allows for multiple pins to be used as 'TX', your application is responsible for initializing APFCON to the correct value for your hardware layout. The mTouch framework will warn you about this when compiling. To remove this warning, uncomment the define at the bottom of mTouch_config.h:

     #define APFCON_INITIALIZED    // For processors with an APFCON register(s), this 
                                   // #define can be uncommented to stop the mTouch 
                                   // Framework from producing a "remember to set 
                                   // APFCON" warning.
                                   //
                                   // RULE OF PROGRAMMING #4: Register bits initialize, 
                                   //      by law, to the value you don't want. Always 
                                   //      explicitly initialize.
    

  2. Program the board normally (not in debug mode) and connect the PKSA to both the PC and the board.

  3. Make sure both the PIC and the PKSA are being supplied with power. Either:
    • Supply power to the PIC from an external source that is also supplying power to the PKSA's PWR and GND pins.
    • Supply power to the PIC from the PKSA by pressing and holding the black button for 3 seconds until the green power LED turns on.
    • Supply power to the PIC from an external source that is NOT connected to the PWR/GND pins of the PKSA and then supply power to the PKSA by pressing on its black button for 3 seconds until the green power LED turns on.
    Note:
    Be careful not to supply power to the PIC from two different sources as you may destroy the board.
  4. Is the PKSA's red LED on?
    If no -

    • Use a scope to verify the TX pin of the PKSA is receiving data from the PIC.
    • If it is, the PKSA's firmware has not been updated to perform as a UART-to-USB converter. See this guide on using the PKSA loader utility to reflash the PICKit Serial Analyzer's firmware.

    If yes - continue to 5.

  5. Determine which COM port has been assigned to the PKSA.
    In Windows -

    • Right click 'My Computer' --> Properties --> Hardware --> Device Manager
    • You should find it listed under "Ports (COM)".

    If it's not there, you need to reinstall the Windows driver for the UART-to-USB behavior. The driver can be found in the PKSA Loader Utility's folder. Correct installation is based on the version of Windows you are using, but can be accomplished by right clicking the file and selecting 'Install' in most cases.

  6. Open the mTouch One-Way GUI and make sure the communication settings are set to:

    • The baud rate you have chosen for MTOUCH_UART_BAUDRATE in mComm_config.h.
    • COM Port dependant on current assignment in Device Manager.