Unable to use UART2

Hi,

I’m beginner with Q2686 and i need to use the second UART on my software.

I have already read the forum and check my code with “ADL User Guide for Open AT® OS v6.20” doc but I’m unable to access to the UART(read or write data).
I use M2MStudio to developp/compile my code and have a Q2686 dev kit to run software.

This is my code:

#include "adl_global.h"
#include "adl_OpenDevice.h"
#include "wm_uart.h"


/***************************************************************************/
/*  Mandatory variables                                                    */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024*3;


/***************************************************************************/
/*  Function   : adl_main                                                  */
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
    u32             handle;
    sUartSettings_t Settings;

    sUartLc_t       uartLc;
    psGItfCont_t    pinterface;

    /* Device */
    Settings.identity = "UART2";
    Settings.role = UART_ROLE_DCE;
    Settings.event_handlers = NULL;

    /* To retrieve the UART SP Interface */
    Settings.interface = &pinterface;

    /* Line Coding */
    uartLc.valid_fields = UART_LC_ALL;
    uartLc.rate         = UART_RATE_9600;
    uartLc.stop         = UART_STOP_BIT_1;
    uartLc.parity       = UART_PARITY_NONE;
    uartLc.data         = UART_DATALENGTH_8;

    Settings.line_coding = &uartLc;

    adl_atSendResponse( ADL_AT_UNS, "UART Struct define\n");
    /*------------------*/
    /* open UART device */
    /*------------------*/
    if( 0 <= (handle = adl_OpenDevice( DF_UART_CLID, &Settings)) )
    {
 	  adl_atSendResponse( ADL_AT_UNS, "successfully opened\n");
       TRACE(( 1, "UART successfully opened" ));

       pinterface->write( handle, "Tx Some bytes", 13 );

       adl_atSendResponse( ADL_AT_UNS, "Close UART\n");
       pinterface->close( handle );
    }
    else
   	  adl_atSendResponse( ADL_AT_UNS, "opening error\n");

    adl_atSendResponse( ADL_AT_UNS, "end software\n");
}

Need help to understand why that doesn’t work …
The board/software always reset at “pinterface->write()” function.

Does this help: viewtopic.php?f=15&t=3314&p=12580&hilit=wmfm#p12580 :question:

No …
Before running software, UART2 is close.

It’s confirm by the at command +WWFM :

AT+WMFM?
+WMFM: 0,2,1,1
+WMFM: 0,2,2,0
+WMFM: 0,2,3,0
+WMFM: 1,2,4,0
+WMFM: 1,2,4,1

And I don’t have problem to open the UART2 with this command :
AT+WMFM=0,1,2
OK
AT+WMFM?
+WMFM: 0,2,1,1
+WMFM: 0,2,2,1
+WMFM: 0,2,3,0
+WMFM: 1,2,4,0
+WMFM: 1,2,4,1
OK

The command +WWFM always indicated the UART2 as close.

Hello,
I have experience the same pb, until I had “Settings.capabilities = NULL;” in the sample code.
I deduct capabilities must be initialised.

Thank’s for your answer but that doesn’t solve my problem.

But when I change the role setting:

/* Device */
    Settings.identity = "UART2";
    Settings.role = UART_ROLE_DCE;
    Settings.event_handlers = NULL;
    Settings.capabilities = NULL;

to

/* Device */
    Settings.identity = "UART2";
    Settings.role = UART_ROLE_NM;
    Settings.event_handlers = NULL;
    Settings.capabilities = NULL;

UART send data. :smiley:

:arrow_right: Find next complet right code to send a text on UART2 :

#include "adl_global.h"
#include "adl_OpenDevice.h"
#include "wm_uart.h"


/***************************************************************************/
/*  Mandatory variables                                                    */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024*3;


/***************************************************************************/
/*  Function   : adl_main                                                  */
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
    u32             handle;
    sUartSettings_t Settings;

    sUartLc_t       uartLc;
    psGItfCont_t    pinterface;

    /* Device */
    Settings.identity = "UART2";
    Settings.role = UART_ROLE_NM;
    Settings.event_handlers = NULL;
    Settings.capabilities = NULL;

    /* To retrieve the UART SP Interface */
    Settings.interface = &pinterface;

    /* Line Coding */
    uartLc.valid_fields = UART_LC_ALL;
    uartLc.rate         = UART_RATE_9600;
    uartLc.stop         = UART_STOP_BIT_1;
    uartLc.parity       = UART_PARITY_NONE;
    uartLc.data         = UART_DATALENGTH_8;

    Settings.line_coding = &uartLc;

    adl_atSendResponse( ADL_AT_UNS, "UART Struct define\n");
    /*------------------*/
    /* open UART device */
    /*------------------*/
    if( 0 <= (handle = adl_OpenDevice( DF_UART_CLID, &Settings)) )
    {
 	  adl_atSendResponse( ADL_AT_UNS, "successfully opened\n");
       TRACE(( 1, "UART successfully opened" ));

       pinterface->write( handle, "Tx Some bytes", 13 );

       adl_atSendResponse( ADL_AT_UNS, "Close UART\n");
       //pinterface->close( handle );
    }
    else
   	  adl_atSendResponse( ADL_AT_UNS, "opening error\n");

    adl_atSendResponse( ADL_AT_UNS, "end software\n");
}