cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in the UART communication between AEK-MCU-C4MLT1 and LTE module

Simone882
Associate II

Hi,

I'm trying to control a LTE module (sim7600e) using an AEK-MCU-C4MLT1 with a serial protocol (UART). The goal is to transmit a simple AT COMMAND, by following these simple steps:

  • Receive "PB DONE" by the LTE module
  • Transmit the AT command
  • Receive an "OK"

I have built a simple state machine in order to follow these simple steps, and I attach the code at the bottom.

I have done 3 tests to see if the code works properly:

  • 1st: Connecting the Chorus 4M to the pc, using a USB adapter, and testing the code with docklight, by sending the responses manually (PB DONE and OK). In this case the code works and it is possible to see that the code enters in all the states.
  • 2nd: By trying to execute the exact same code with a NUCLEO F446RET6 connected to the LTE module. The communication works perfectly, without a single error.
  • 3rd: By connecting the Chorus to the NUCLEO and using this one's UART to send the responses, also this approach works very well.

Then I tried to connect the Chorus 4M to the LTE module, but the communication does not work. In particular the Chorus receives the PB DONE, but thein it fails at sending the AT command, even if it enters in the tx interrupt I am not able to see the AT command at the receiver, thus implies that the code does not enter in the state in which it reads the OK in response.

Do you ever had a similar problem?

Do you know how to fix this issue?

Thanks in advance,

Simone.

uint8_t typedChar[1] = " ";

char message[64];

char text[1000];

uint8_t u8State = 0;

uint32_t StartTime = 0;

uint32_t timeout = 2000;

uint8_t u8Tx_Cmplt = 0;

int main(void) {

/* Initialization of all the imported components in the order specified in

   the application wizard. The function is generated automatically.*/

componentsInit();

/* Uncomment the below routine to Enable Interrupts. */

irqIsrEnable();

sd_lld_start(&SD6, &serial_config_custom_uart);

(void)sd_lld_read(&SD6, typedChar, 1);

/* Application main loop.*/

for ( ; ; ) { if(u8State == 0 )

{

if(strstr((char *)text,"PB DONE\r\n"))

{

memset(text,0,sizeof(text));

u8State++;

}

}

else if(u8State == 1 )

{

strncpy (message, "\r\nATE1\r\n", sizeof("\r\nATE1\r\n"));

(void)sd_lld_write(&SD6, (uint8_t *) message, (uint16_t) strlen(message)); u8State++;

}

else if(u8State == 2 )

{

if(u8Tx_Cmplt == 1)

{

u8Tx_Cmplt = 0;

u8State++;

}

StartTime = sysGetMilliseconds();

}

else if(u8State == 3 )

{ if(strstr((char *)text,"\r\nOK\r\n"))

{

memset(text,0,sizeof(text));

u8State++;

}

if (StartTime + timeout > sysGetMilliseconds())

{

u8State=1;

}

}

else if(u8State == 4 )

{

u8State++;

}

osalThreadDelayMilliseconds(1000);

}

}

void tx_callback(SerialDriver *sdp){

(void)sdp;

u8Tx_Cmplt = 1;

}

void rx_callback(SerialDriver *sdp){

(void)sdp;

strcat(text, (char *)typedChar);

}

1 ACCEPTED SOLUTION

Accepted Solutions
ODOUV.1
ST Employee

Hello,

it works better on my side with this code:

int main(void) {

 /* Initialization of all the imported components in the order specified in

   the application wizard. The function is generated automatically.*/

 componentsInit();

 /* Enable Interrupts */

 irqIsrEnable();

 sd_lld_start(&SD5, &serial_config_custom_uart);

/* Application main loop.*/

for (;;) {

(void) sd_lld_read(&SD5, typedChar, 1);

if (u8State == 0) {

if (strstr((char*) text, "PB DONE\r")) {

memset(text, 0, sizeof(text));

u8State++;

}

} else if (u8State == 1) {

u8Tx_Cmplt = 0;

strncpy((void*)message, "\r\nATE1\r\n", sizeof("\r\nATE1\r\n"));

(void) sd_lld_write(&SD5, (uint8_t*) message,

(uint16_t) strlen((void*)message));

u8State++;

} else if (u8State == 2) {

if (u8Tx_Cmplt > 0) {

u8Tx_Cmplt = 0;

u8State++;

}

StartTime = sysGetMilliseconds();

} else if (u8State == 3) {

if (strstr((char*) text, "OK\r")) {

memset(text, 0, sizeof(text));

u8State++;

}

else if (StartTime + timeout > sysGetMilliseconds()) {

//memset(text, 0, sizeof(text));

u8State = 1;

}

} else if (u8State == 4) {

strncpy((void*)message, "\r\nEND\r\n", sizeof("\r\nEND\r\n"));

(void) sd_lld_write(&SD5, (uint8_t*) message,

(uint16_t) strlen((void*)message));

memset(text, 0, sizeof(text));

u8State = 0;

}

osalThreadDelayMilliseconds(50);

}

}

Buon Natale !

View solution in original post

2 REPLIES 2
ODOUV.1
ST Employee

Hello,

it works better on my side with this code:

int main(void) {

 /* Initialization of all the imported components in the order specified in

   the application wizard. The function is generated automatically.*/

 componentsInit();

 /* Enable Interrupts */

 irqIsrEnable();

 sd_lld_start(&SD5, &serial_config_custom_uart);

/* Application main loop.*/

for (;;) {

(void) sd_lld_read(&SD5, typedChar, 1);

if (u8State == 0) {

if (strstr((char*) text, "PB DONE\r")) {

memset(text, 0, sizeof(text));

u8State++;

}

} else if (u8State == 1) {

u8Tx_Cmplt = 0;

strncpy((void*)message, "\r\nATE1\r\n", sizeof("\r\nATE1\r\n"));

(void) sd_lld_write(&SD5, (uint8_t*) message,

(uint16_t) strlen((void*)message));

u8State++;

} else if (u8State == 2) {

if (u8Tx_Cmplt > 0) {

u8Tx_Cmplt = 0;

u8State++;

}

StartTime = sysGetMilliseconds();

} else if (u8State == 3) {

if (strstr((char*) text, "OK\r")) {

memset(text, 0, sizeof(text));

u8State++;

}

else if (StartTime + timeout > sysGetMilliseconds()) {

//memset(text, 0, sizeof(text));

u8State = 1;

}

} else if (u8State == 4) {

strncpy((void*)message, "\r\nEND\r\n", sizeof("\r\nEND\r\n"));

(void) sd_lld_write(&SD5, (uint8_t*) message,

(uint16_t) strlen((void*)message));

memset(text, 0, sizeof(text));

u8State = 0;

}

osalThreadDelayMilliseconds(50);

}

}

Buon Natale !

Simone882
Associate II

Thank you very much!