I am using the following code to open UART2 and configure 9600 baud rate.
I always get: Res_WMFM1_Handler +CME ERROR: 3 (operation not allowed).
Although the UART2 is opened (and switched to data mode - code not included), the baud rate is 115200 (default rate) even when I explictly set to 9600.
How do I modify the baud rate of UART2?
bool Res_IPR_Handler ( void )
{
return FALSE;
}
bool Res_WMFM1_Handler ( adl_atResponse_t *paras )
{
char strOut[255];
ascii *rsp;
rsp = (ascii *)adl_memGet(paras->StrLength);
wm_strRemoveCRLF(rsp, paras->StrData, paras->StrLength);
sprintf(strOut, "Res_WMFM1_Handler %s", rsp);
adl_atSendResponse ( ADL_AT_UNS, strOut);
adl_atCmdCreate( "AT+IPR=9600", ADL_AT_PORT_TYPE( ADL_AT_UART2, FALSE ), (adl_atRspHandler_t)Res_IPR_Handler, "*", NULL );
adl_atCmdCreate( "AT+IFC=0,0", ADL_AT_PORT_TYPE( ADL_AT_UART2, FALSE ), (adl_atRspHandler_t)Res_IPR_Handler, "*", NULL );
UART2_Handle = adl_fcmSubscribe( ADL_FCM_FLOW_V24_UART2, (adl_fcmCtrlHdlr_f)hnd_fcmCtrl_U1, (adl_fcmDataHdlr_f)hnd_fcmData_U1 );
if(wm_strncmp(rsp, "OK", 2) == 0)
{
}
else if(!wm_strncmp(rsp, "+CME: Error", strlen("+CME: Error")))
{
adl_atSendResponse ( ADL_AT_UNS, rsp);
}
adl_memRelease(rsp);
return FALSE;
}
void UART2_Enable ( void )
{
adl_atCmdCreate( “AT+WMFM=0,1,2”, FALSE, (adl_atRspHandler_t)Res_WMFM1_Handler, “*”, NULL );
return;
}