1 Reply Latest reply on Aug 29, 2020 10:28 AM by DheerajK_81

    cyhal_timer in HAL for MBed OS fails to compile

    GuGa_1322886

      I'm working with Mbed Studio 6.1 and CY8CPROTO-062-4343W on a project with MBed OS 6.2

      Following the sample code of the HAL documentation I created the following functions:

       

      #include "mbed.h"

       

      #include "cyhal.h"

      #include "displayThread.h"


      bool timer_interrupt_flag = false;

      cyhal_timer_t timer_obj;


      static void isr_timer(void *callback_arg, cyhal_timer_event_t event)

      {

          (void) callback_arg;

          (void) event;

          /* Set the interrupt flag and process it from the application */

          timer_interrupt_flag = true;

          displaySendUpdateTime();

      }


      cy_rslt_t initPeriodicTimer()

      {

          cy_rslt_t rslt;


          const cyhal_timer_cfg_t timer_cfg =

          {

              .compare_value = 0,                 /* Timer compare value, not used */

              .period = 999,                      /* Defines the timer period */

              .direction = CYHAL_TIMER_DIR_UP,    /* Timer counts up */

              .is_compare = false,                /* Don't use compare mode */

              .is_continuous = true,              /* Run the timer indefinitely */

              .value = 0                          /* Initial value of counter */

          };


          /* Initialize the timer object. Does not use pin output ('pin' is NC) and

           * does not use a pre-configured clock source ('clk' is NULL). */

          rslt = cyhal_timer_init(&timer_obj, NC, NULL);


          if ( rslt == CY_RSLT_SUCCESS)

          {

              /* Apply timer configuration such as period, count direction, run mode, etc. */

              rslt = cyhal_timer_configure(&timer_obj, &timer_cfg);

              if ( rslt == CY_RSLT_SUCCESS)

              {

                  rslt = cyhal_timer_set_frequency(&timer_obj, 1000);

                  /* Start the timer with the configured settings */


                  if ( rslt == CY_RSLT_SUCCESS)

                  {

                          /* Assign the ISR to execute on timer interrupt */

                      cyhal_timer_register_callback(&timer_obj, isr_timer, NULL);

                      /* Set the event on which timer interrupt occurs and enable it */

                      cyhal_timer_enable_event(&timer_obj, CYHAL_TIMER_IRQ_TERMINAL_COUNT, 3, true);


                      rslt = cyhal_timer_start(&timer_obj);

                  }

              }

          }

          return rslt;

      }

       

      When compiling the project I get the following 2 errors (timerISR.cpp is my function above):

      [Error] @0,0: L6218E: Undefined symbol cyhal_tcpwm_enable_event(TCPWM_V1_Type*, cyhal_resource_inst_t*, unsigned, unsigned char, bool) (referred from BUILD/CY8CPROTO_062_4343W/ARMC6/timerISR.o).

      [Error] @0,0: L6218E: Undefined symbol cyhal_tcpwm_register_callback(cyhal_resource_inst_t*, void(*)(), void*) (referred from BUILD/CY8CPROTO_062_4343W/ARMC6/timerISR.o).

       

      Those functions are defined as follows in cyhal_timer_impl.h:

       

      #define cyhal_timer_register_callback(obj, callback, callback_arg) cyhal_timer_register_callback_internal(obj, callback, callback_arg)

       

      and

       

      #define cyhal_timer_enable_event(obj, event, intr_priority, enable) cyhal_timer_enable_event_internal(obj, event, intr_priority, enable)

       

       

      but I can't find the ultimate ..internal() targets anywhere...