4 Replies Latest reply on Aug 17, 2015 4:11 AM by arun.john

    Program starts successfully after device is programmed using the

    arun.john

      Hi,

         

       

         

      I am using the CY8CKIT-049-42XX PSOC 4 prototyping kit to develop a program to control a RN171 wifi module (http://www.microchip.com/wwwproducts/Devices.aspx?product=RN171), the program uses the following interrupts.

         

      1. Timer 1

         

      2. USART (USB -Serial )

         

      3. USART (Tx-P1.3,Rx-P1.4)

         

       

         

      The program works very well as expected when programmed from the host bootloader , all the interrupts are received correctly.

         

      However when the prototype kit is powered up from an external power supply, the program just hangs up, and does to come to the for(;;)  loop, this I know because pressing the push button does not bring the kit into program mode (LED does not flash), but when the same is done after programming from the host bootloader the kit comes into program mode when the push button is pressed.

         

      Please see the attached workspace bundle for reference.

         

      The main file code and the timer1 interrupt handler is given below,

         

       

         
          


      int main()
      {   
          int a;
              
          /* Enable the global interrupt */
          CyGlobalIntEnable;
          
          //TimerISR_Start();
          TimerISR_StartEx(InterruptHandler);       
          //TimerISR_Enable();
          
          Timer_1_Start();       
          PCUART_Start();
          HC05UART_Start();
          
          
          LED_Write(0);
          
          //configure as web client

          

          InitNetworkProfiles();
          
          RN171IdleTime=200;
          //RN171WifiJoin.Task=RN171WIFIJOIN_INIT;
          
          //transfer uart data to wifi
          //RN171UARTMode=2;
         
          
          Control.Task=1;
          PCUART_UartPutString("started\n\r");

          


          
          for(;;)
          {      
                     
              application();
             
              
              if(!SW1_Read()) {
                  LED_Write(1);
                  CySoftwareReset();
              }

          


              
          }
      }

         
         

      /*******************************************************************************
      * Define Interrupt service routine and allocate an vector to the Interrupt
      ********************************************************************************/
      CY_ISR(InterruptHandler)
      {
          /* Read Status register in order to clear the sticky Terminal Count (TC) bit 
           * in the status register. Note that the function is not called, but rather 
           * the status is read directly.
           */
             Timer_1_STATUS;
          //Timer_1_ClearFIFO();
          //TimerISR_ClearPending();
          
          //timer interrupts at 2 msec ticks
              //ThwScanTimeout++;
          
          RN171WaitTimeout++;
          RN171ScanTimeout++;
          
          if (RN171RcvCntr!=0){

         

              RN171RcvTimeout++;
              if (RN171RcvTimeout>RN171IdleTime){
                                   
                  RN171RcvLen=RN171RcvCntr;
                  //clear timeout condition
                  RN171RcvCntr=0;
                  RN171RcvTimeout=0;
                  
                  //set ready flag
                  RN171DataReadyFlg=1;      
              }
          }
          
         
          //timeout, also triggers data ready flag indicating packet is ready
          if (UARTRcvCntr!=0){

         

              UARTRcvTimeout++;
              if (UARTRcvTimeout>BTH_IDLE_TIMEOUT){
                                   
                  rcvlen=UARTRcvCntr;
                  //clear timeout condition
                  UARTRcvCntr=0;
                  UARTRcvTimeout=0;
                  
                  //set ready flag
                  UARTDataReadyFlg=1;      
              }
          }              
      }

         

      Could anyone help me please???, I am sure something basic is missing here...

         

      thanks

         

      a