Problem with UART2 Q24Plus

Hello

I’m trying to receive data through UART2, but i get nothing. I’m using this code:

s8  bUART2Handler;
                s8 bUARTok = -1;

	//4800
                adl_atCmdCreate("AT+IPR=4800", ADL_FCM_FLOW_V24_UART2, fnBCN13A_UART2HandlerIPR, "*", NULL ); 
                // 8, n, 1
	adl_atCmdCreate("AT+ICF=3,4", ADL_FCM_FLOW_V24_UART2, fnBCN13A_UART2HandlerICF, "*", NULL );

	//Open UART2 
	bUARTok = adl_atCmdCreate("AT+WMFM=0,1,2",FALSE,fnBCN13A_UART2Handler,"*",NULL);
	
	bUART2Handler = -1;

	if(!bUARTok)
	{
		bUART2Handler = adl_fcmSubscribe(ADL_FCM_FLOW_V24_UART2,fnBCN13A_UART2CtrlHandler,fnBCN13A_UART2DataHandler);

		if(bUART2Handler >= 0)
			adl_atSendResponse ( ADL_AT_UNS, "\n\r FCM UART 2 OK \n\r");
	}
	else
		adl_atSendResponse ( ADL_AT_UNS, "\n\r Error Opening UART2 \n\r");

I never get anything on fnBCN13A_UART2DataHandler, can anyone help ?

Regards
leohen

Hello leohen,

What you do is right, but you need to set the data mode for Uart2. You can do it in your control handler like this:

bool fnBCN13A_UART2CtrlHandler(adl_fcmEvent_e Event)
{
	switch(Event)
	{
		case ADL_FCM_EVENT_FLOW_OPENNED:
                        adl_atSendResponse ( ADL_AT_UNS, "\n\r FCM UART 2 is now opened \n\r");
			if (adl_fcmSwitchV24State(bUART2Handler, ADL_FCM_V24_STATE_DATA) == OK)
			        adl_atSendResponse ( ADL_AT_UNS, "\n\r FCM UART 2 is now in data mode \n\r");
			break;
		case ADL_FCM_EVENT_FLOW_CLOSED:
		        adl_atSendResponse ( ADL_AT_UNS, "\n\r FCM UART 2 is now closed \n\r");
			break;
	}
	return TRUE;
}

Regards,

wismo_coder

Wismo_Coder

Thanks for your help, its working now.

Best Regards
Leohen

Hello

Another doubt, i set baud rate and flow control before opening the port, but it doesn´t change, can anyone help ?

Regards
Leohen

In order to change the baud rate aof UART2 you have to issue the command directly on UART2 when it is in AT command mode, or from your program like this:

adl_atCmdCreate("AT+IPR=9600\r", ADL_AT_PORT_TYPE(ADL_PORT_UART2,FALSE), (adl_atRspHandler_t) NULL, NULL);

Do this after you succesfully switched to data mode.
As for the flow control: there is no hardware flow control for UART2 if that’s what you mean.

Regards,

wismo_coder

Wismo_coder

Thanks again for your help. It´s working now.

Best Regards
Leohen