1 Reply Latest reply on Jun 9, 2016 10:00 AM by MichelleC_Intel

    qm_uart_write use

    jschimpf

      Hi,

      How do you use this function in the D2000.  I have a uart index of 8 (opened uart with 115200 baud using code from SERIAL example).  And sending a data value 0f 0x41 (i.e. ASCII 'A').  I then get a return value of 22 (0x16) what does this mean ?  This value is not present in the qm_uart_status_ enumeration so is it a combination of values ?

       

      Thank you.

       

      --jim schimpf

        • 1. Re: qm_uart_write use
          MichelleC_Intel

          Hi Jim ,

           

          qm_uart_write performs a single character write on the UART interface. This is a blocking synchronous call.

           

          The example below is a simple use of the qm_uart_read and qm_uart_write functions. This will read everything from the UART RX buffer and Echo it to the TX.

          (If you are using ISSM just load the UART example and replace the main.c contents with the below)

           

          #include "qm_pinmux.h"

          #include "qm_uart.h"

          #include "qm_interrupt.h"

          #include "qm_scss.h"

           

           

          #define BIG_NUMBER_RX (50)

          static uint8_t rx_buffer[BIG_NUMBER_RX];

           

           

          int main(void)

          {

            qm_uart_config_t cfg, rd_cfg;

            cfg.baud_divisor = QM_UART_CFG_BAUD_DL_PACK(0, 17, 6);

            cfg.line_control = QM_UART_LC_8N1;

            cfg.hw_fc = false;

           

          /* Mux out UART0 tx/rx pins and enable input for rx. */

           

            qm_pmux_select(QM_PIN_ID_12, QM_PMUX_FN_2);

            qm_pmux_select(QM_PIN_ID_13, QM_PMUX_FN_2);

            qm_pmux_input_en(QM_PIN_ID_13, true);

           

           

            clk_periph_enable(CLK_PERIPH_CLK | CLK_PERIPH_UARTA_REGISTER);

            qm_uart_set_config(QM_UART_0, &cfg);

            qm_uart_get_config(QM_UART_0, &rd_cfg);

           

           

            while(1)

            {

            while(qm_uart_get_status(QM_UART_0) != QM_UART_IDLE ){

               qm_uart_read(QM_UART_0, rx_buffer);

               qm_uart_write(QM_UART_0, rx_buffer[0]); }

                    /*  QM_PRINTF("No Data in RX Buffer \n");*/ }

           

           

            return 0;

          }