2 Replies Latest reply on Oct 16, 2019 5:33 PM by MoTa_728816

    Troubleshooting issue with PSoC UART component and communicating with cellular modem

    SaRi_4418481

      Hello,

       

      I am using a custom board that is similar to the CY8CKIT-050 Cypress Development Kit. I am having an issue troubleshooting my communication through a Nimbelink 4G LTE modem that I am connecting to it via an XBee Breakout Board, and wanted to post some basic code here to ensure my issues are hardware (rather than a mistake in my firmware code).

       

      I am communicating with the modem using a UART 2.5 component. I have been able to read data from my Rx buffer only once (the Nimbelink 7588 module will output "+PBREADY" when it is ready to communicate, which I was able to read before sending it a message). However, I have not yet been successful sending a message and receiving the expected response.

       

      I have attached the project here in case anyone would like to assist by looking over the code on my behalf. Otherwise, this is the general Rx interrupt routineI am utilizing to read characters from the Rx buffer:

       

      UART_modem_PutString("ATE1\r");

       

      CY_ISR(modem_rx_isr){

          while(UART_modem_GetRxBufferSize()){

              rx_char = UART_modem_GetChar();

              if (rx_char){

                  modem_received_buffer[uart_string_index] = rx_char;

                  uart_string_index++;

              }

          }

      }

       

       

      Thank you in advance for any assistance.

       

      Sincerely,

      SR

        • 1. Re: Troubleshooting issue with PSoC UART component and communicating with cellular modem
          AH_96

          Hi SaRi_4418481

           

          The code that is shared does not include a forever loop, so the code execution occurs only once and then the program stops. Since you are receiving "+PBREADY" from the controller, it means that the UART interfacing is successful, but the code might skip the ATE command.

          Please add a loop to keep sending the AT commands after a timeout. You can also probe the lines to see if the data is being transmitted correctly.

          The code can also have conditional statements to make sure that the AT commands are sent only after "+PBREADY" is received.

           

          Thanks and regards

          Hari

          • 2. Re: Troubleshooting issue with PSoC UART component and communicating with cellular modem
            MoTa_728816

            Hi,

             

            First of all, I agree with Hari-san, you should have

            ==============

            for (;;) {

            }

            ==============

            at the last part of main() to prevent the MCU runaway.

            ==============

            main()

            {

            ....

               for(;;) {

               }

            }

            ==============

             

            About your general function

            ==============

            CY_ISR(modem_rx_isr){

                while(UART_modem_GetRxBufferSize()){

                    rx_char = UART_modem_GetChar();

                    if (rx_char){

                        modem_received_buffer[uart_string_index] = rx_char;

                        uart_string_index++;

                    }

                }

            }

            ==============

             

            I would reset uart_string_index when exiting while()

            so that we can receive the next string.

            ==============

            CY_ISR(modem_rx_isr){

                while(UART_modem_GetRxBufferSize()){

                    rx_char = UART_modem_GetChar();

                    if (rx_char){

                        modem_received_buffer[uart_string_index] = rx_char;

                        uart_string_index++;

                    }

                }

                modem_received_buffer[uart_string_index] = 0 ; /* terminate the string */

                uart_string_index = 0 ; /* reset the index */

            }

            ==============

             

            Also, if we can expect that modem put EOL ('\r' or '\n') after its string, I would do.

            ==============

            CY_ISR(modem_rx_isr){

                while(UART_modem_GetRxBufferSize()){

                    rx_char = UART_modem_GetChar();

                    if (rx_char){

                        if ((rx_char == '\r')||(rx_char == '\n')) { /* line end detected. */

                           break ;

                        } else {

                           modem_received_buffer[uart_string_index] = rx_char;

                           uart_string_index++;

                        }

                    }

                }

                modem_received_buffer[uart_string_index] = 0 ; /* terminate the string */

                uart_string_index = 0 ; /* reset the index */

            }

            ==============

             

            moto