9 Replies Latest reply on Jul 18, 2016 6:11 PM by userc_20416

    WICED 3.7.0 -- Timed Event with 1ms timer fails to run after init

      Hi.

       

      I have a 1ms timed event that is supposed to poll a GPIO input every time it runs.

       

      However, after boot up the timed event only runs once.

       

      If I change the time period to 5 ms, the timed event seems to run the function quite regularly.

       

      /******************************************************

      *                    Constants

      ******************************************************/

      #define SAMPLING_PERIOD (1 * MILLISECONDS)

      #define BUTTON (WICED_GPIO_26) //Pin 30

      #define RELAY_CTRL_OUTPUT (WICED_GPIO_23)

      #define BUTTON_STATE_PERSISTENCE_WAIT_TIME (100)

       

      /******************************************************

      *               Static Function Declarations

      ******************************************************/

      static wiced_result_t sampling_thread(void* arg);

       

       

      /******************************************************

      *               Variable Definitions

      ******************************************************/

      static wiced_timed_event_t button_sampling_timed_event;

      /* relay */

      static wiced_bool_t g_relay_state = WICED_FALSE;

       

       

      void application_start( )

      {

          /* Initialise the WICED device */

          wiced_init();

       

          /* initialize the button input */

          /* button input */

          if( wiced_gpio_init( BUTTON, INPUT_HIGH_IMPEDANCE ) == WICED_SUCCESS ) {

              printf("Success: Button is set as GPIO i/p with high impedance\n");

          } else {

              printf("Failure: Button is set as GPIO i/p with high impedance\n");

          }

       

          /* initialize the relay to open */

          g_relay_state = WICED_FALSE;

          wiced_gpio_output_low(RELAY_CTRL_OUTPUT);

       

         /* Setup a timed event that will toggle RGB leds */

          wiced_rtos_register_timed_event( &button_sampling_timed_event, WICED_HARDWARE_IO_WORKER_THREAD, sampling_thread, SAMPLING_PERIOD, 0 );

      }

       

      static wiced_result_t sampling_thread(void* arg)

      {

          UNUSED_PARAMETER( arg );

          current_button_state = wiced_gpio_input_get( BUTTON ) ? WICED_TRUE : WICED_FALSE;

          printf("current_button_state = %u\n", current_button_state);

        

         return WICED_SUCCESS;

      }

       

      This is on Inventek's ISM43341_M4G_L44 platform.