Troubleshooting issue with PSoC UART component and communicating with cellular modem

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
SaRi_4418481
Level 1
Level 1

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

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

View solution in original post

0 Likes
2 Replies