2 Replies Latest reply on May 13, 2020 1:58 AM by MoTa_728816

    HOW TO DEBBUG A SELECT PROGRAM... I AM NOT ABLE TO EXECUTE THE STEPS??

    Rach_4524011

      HOW TO DEBBUG A SELECT PROGRAM... I AM NOT ABLE TO EXECUTE THE STEPS??

       

      #include <project.h>

      #include <string.h>

      #include <stdio.h>

      #include <stdlib.h>

      #include <math.h>

       

       

      void config(void);

      char ch,ch1;

      char str[100],str1[100];

      int i = 0,j = 0;

       

       

      CY_ISR(ISRCmdHandler)           // interrupt handler for CMD

      {

          ch = UART_CMD_UartGetChar();     //connect

          UART_CMD_ClearRxInterruptSource(UART_CMD_GetRxInterruptSourceMasked());

          if(ch != '\n')

          {

              str[i] = ch;

              i++;

          }

          else

          {

              i = 0;

              config();

              memset(str,0,sizeof(str));

      //        UART_GSM_UartPutString(str);      

          }

      //    UART_CMD_UartPutChar(ch);

      }

       

       

      CY_ISR(ISRgsmHandler)           // interrupt handler for GSM

      {

          ch1 = UART_GSM_UartGetChar();  

          UART_GSM_ClearRxInterruptSource(UART_GSM_GetRxInterruptSourceMasked());

          if(ch1 != '\n')

          {

              str1[j] = ch1;

              j++;

          }

          else

          {

              j = 0;

              UART_CMD_UartPutString(str1);

      //        config();

              memset(str1,0,sizeof(str1));

          }

      //    UART_GSM_UartPutChar(ch);

      }

       

       

      void config(void)

      {

          if(strcmp(str,"CONNECT") == 0)

          {

              UART_GSM_UartPutString("AT");

              CyDelay(500);

              UART_GSM_UartPutString("AT+NETCLOSE");

              CyDelay(500);

              UART_GSM_UartPutString("AT+CSOCKSETPN=1");

              CyDelay(500);

              UART_GSM_UartPutString("AT+CIPMODE=0");

              CyDelay(500);

              UART_GSM_UartPutString("AT+NETOPEN");

              CyDelay(500);

              UART_GSM_UartPutString("AT+IPADDR");

              CyDelay(500);

      //        UART_GSM_UartPutString("AT+CIPOPEN=0/");

      //        UART_GSM_UartPutString("/");

            

            

            

          }

      //    else if(strcmp(str1,"OK") == 0){

      //      

      //    }

        

      }

       

       

       

       

      int main(void)

      {

          UART_CMD_Start();

          UART_GSM_Start();

          ISR_CMD_StartEx(ISRCmdHandler);

          ISR_GSM_StartEx(ISRgsmHandler);

          UART_CMD_UartPutString("UART 1 START\n\r");

          UART_GSM_UartPutString("UART 2 START \n\r");

          CyGlobalIntEnable;

          for(;;)

          {        

          }

      }

       

       

       

       

      /* [] END OF FILE */

        • 1. Re: HOW TO DEBBUG A SELECT PROGRAM... I AM NOT ABLE TO EXECUTE THE STEPS??
          Rach_4524011

          #include <project.h>

          #include <string.h>

          #include <stdio.h>

          #include <stdlib.h>

          #include <math.h>

           

           

          void config(void);

          char ch,ch1;

          char str[100],str1[100];

          int i = 0,j = 0;

           

           

          CY_ISR(ISRCmdHandler)           // interrupt handler for CMD

          {

              ch = UART_CMD_UartGetChar();     //connect

              UART_CMD_ClearRxInterruptSource(UART_CMD_GetRxInterruptSourceMasked());

              if(ch != '\n')

              {

                  str[i] = ch;

                  i++;

              }

              else

              {

                  i = 0;

                  config();

                  memset(str,0,sizeof(str));

          //        UART_GSM_UartPutString(str);       

              }

          //    UART_CMD_UartPutChar(ch);

          }

           

           

          CY_ISR(ISRgsmHandler)           // interrupt handler for GSM

          {

              ch1 = UART_GSM_UartGetChar();   

              UART_GSM_ClearRxInterruptSource(UART_GSM_GetRxInterruptSourceMasked());

              if(ch1 != '\n')

              {

                  str1[j] = ch1;

                  j++;

              }

              else

              {

                  j = 0;

                  UART_CMD_UartPutString(str1);

          //        config();

                  memset(str1,0,sizeof(str1));

              }

          //    UART_GSM_UartPutChar(ch);

          }

           

           

          void config(void)

          {

              if(strcmp(str,"CONNECT") == 0)

              {

                  UART_GSM_UartPutString("AT");

                  CyDelay(500);

                  UART_GSM_UartPutString("AT+NETCLOSE");

                  CyDelay(500);

                  UART_GSM_UartPutString("AT+CSOCKSETPN=1");

                  CyDelay(500);

                  UART_GSM_UartPutString("AT+CIPMODE=0");

                  CyDelay(500);

                  UART_GSM_UartPutString("AT+NETOPEN");

                  CyDelay(500);

                  UART_GSM_UartPutString("AT+IPADDR");

                  CyDelay(500);

          //        UART_GSM_UartPutString("AT+CIPOPEN=0/");

          //        UART_GSM_UartPutString("/");

                 

                 

                 

              } 

          //    else if(strcmp(str1,"OK") == 0){

          //       

          //    }

             

          }

           

           

           

           

          int main(void)

          {

              UART_CMD_Start(); 

              UART_GSM_Start(); 

              ISR_CMD_StartEx(ISRCmdHandler);

              ISR_GSM_StartEx(ISRgsmHandler);

              UART_CMD_UartPutString("UART 1 START\n\r");

              UART_GSM_UartPutString("UART 2 START \n\r");

              CyGlobalIntEnable;

              for(;;)

              {         

              }

          }

           

           

           

           

          /* [] END OF FILE */

          • 2. Re: HOW TO DEBBUG A SELECT PROGRAM... I AM NOT ABLE TO EXECUTE THE STEPS??
            MoTa_728816

            Hi,

             

            Please do not call lengthy function such as config in an ISR.

             

            I would touch your main.c like below to make it easier for me to understand.

            And please be careful about overflow of the receive buffer.

            In general, you don't have to fill 0 to a str array, but make the index to 0 and

            may be write 0 at the first letter.

             

            I wonder if this can be "stepped".

             

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

            /* ========================================

            *

            * Copyright YOUR COMPANY, THE YEAR

            * All Rights Reserved

            * UNPUBLISHED, LICENSED SOFTWARE.

            *

            * CONFIDENTIAL AND PROPRIETARY INFORMATION

            * WHICH IS THE PROPERTY OF your company.

            *

            * ========================================

            */

            #include <project.h>

            #include <string.h>

            #include <stdio.h>

            #include <stdlib.h>

            #include <math.h>

             

            #define CMD_BUF_LEN 100

            #define GSM_BUF_LEN 100

             

            void config(char *cmd);

             

            volatile char cmd_buf[CMD_BUF_LEN+1] ;

            volatile char gsm_buf[GSM_BUF_LEN+1] ;

             

            volatile int cmd_rx_index = 0 ;

            volatile int gsm_rx_index = 0 ;

            volatile int cmd_line_received = 0 ;

            volatile int gsm_line_received = 0 ;

             

            CY_ISR(ISRCmdHandler)           // interrupt handler for CMD

            {

                char ch ;

             

                UART_CMD_ClearRxInterruptSource(UART_CMD_GetRxInterruptSourceMasked());

                if ((UART_CMD_SpiUartGetRxBufferSize()==0)||cmd_line_received) { /* if no char received retrun */

                    return ;

                }

                ch = UART_CMD_UartGetChar();    

                if(ch != '\n')

                {

                    cmd_buf[cmd_rx_index] = ch;

                    cmd_rx_index++;

                    if (cmd_rx_index >= CMD_BUF_LEN) {

                        cmd_buf[CMD_BUF_LEN] = 0 ;

                        cmd_line_received = -1 ;

                        cmd_rx_index = 0 ;

                    }

                }

                else

                {

                    cmd_line_received = 1 ;

                    cmd_buf[cmd_rx_index] = 0 ; /* terminate the string */

                    cmd_rx_index = 0;      

                }

            }

             

             

            CY_ISR(ISRgsmHandler)           // interrupt handler for GSM

            {

                char ch1 ;

               

                UART_GSM_ClearRxInterruptSource(UART_GSM_GetRxInterruptSourceMasked());

                if ((UART_GSM_SpiUartGetRxBufferSize()==0)||gsm_line_received) { /* if no char received retrun */

                    return ;

                }

                ch1 = UART_GSM_UartGetChar();  

                if(ch1 != '\n')

                {

                    gsm_buf[gsm_rx_index] = ch1;

                    gsm_rx_index++;

                    if (gsm_rx_index >= GSM_BUF_LEN) {

                        gsm_buf[GSM_BUF_LEN] = 0 ;

                        gsm_line_received = -1 ; /* buffer over flow */

                        gsm_rx_index = 0 ;

                    }

                }

                else

                {

                    gsm_buf[gsm_rx_index] = 0 ; /* terminate the string */

                    gsm_line_received = 1 ;      

                    gsm_rx_index = 0;

                }

            }

             

             

            void config(char *cmd)

            {

                if(strcmp(cmd,"CONNECT") == 0)

                {

                    UART_GSM_UartPutString("AT");

                    CyDelay(500);

                    UART_GSM_UartPutString("AT+NETCLOSE");

                    CyDelay(500);

                    UART_GSM_UartPutString("AT+CSOCKSETPN=1");

                    CyDelay(500);

                    UART_GSM_UartPutString("AT+CIPMODE=0");

                    CyDelay(500);

                    UART_GSM_UartPutString("AT+NETOPEN");

                    CyDelay(500);

                    UART_GSM_UartPutString("AT+IPADDR");

                    CyDelay(500);

            //        UART_GSM_UartPutString("AT+CIPOPEN=0/");

            //        UART_GSM_UartPutString("/");

                }

            //    else if(strcmp(cmd,"OK") == 0){

            //      

            //    }

            }

             

             

            int main(void)

            {

                UART_CMD_Start();

                UART_GSM_Start();

                ISR_CMD_StartEx(ISRCmdHandler);

                ISR_GSM_StartEx(ISRgsmHandler);

                UART_CMD_UartPutString("UART 1 START\n\r");

                UART_GSM_UartPutString("UART 2 START \n\r");

             

             

                CyGlobalIntEnable;

             

             

                for(;;)

                {        

                    if (cmd_line_received) {

                        config((char *)cmd_buf);

                        cmd_rx_index = 0 ;

                        cmd_buf[cmd_rx_index] = 0 ;

                        // memset(str,0,sizeof(str)); // this is not necessary

                        cmd_line_received = 0 ;

                    }

                    if (gsm_line_received) {

                        UART_CMD_UartPutString((char *)gsm_buf);

                        gsm_rx_index = 0 ;

                        gsm_buf[gsm_rx_index] = 0 ;

                        // memset(str1,0,sizeof(str1)); // this is not necessary     

                        gsm_line_received = 0 ;

                    }

                }

            }

             

            /* [] END OF FILE */

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

             

            moto