Timer Function implimentation in S32k

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timer Function implimentation in S32k

274 Views
akhilranga
Contributor IV
Hi there,
 
I am trying to build an Automotive application using S32k14x EAR SDK. In this i have few use cases which i want to acheive, but i belive i require a timer module to acheive them. 
 Mentionoing couple of use cases.
 
Use Case 1: Want to change the state of  an Output pin High or Low after some milliseconds.  when i receive a high signal from an Input Pin. 
 
Use Case 2 : I want detect the duration of the pressed Push Button Input. i.e i want to apply a function to a push button upon pressing it for "x" milliseconds i need to get a confirmation/acknowledgement signal.
 
i belive these can be acheived using FTM OC component. But it would be helpful if any example codes are available for reference to acheive the above functions
0 Kudos
1 Reply

254 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @akhilranga,

For Use Case 1, you can look into this example: Example: S32K148 GPIO Interrupt - NXP Community, pressing SW4 invoke interrupt and Interrupt handler toggles Green LED. If you need some specific time after the interruption, an implementation of the LPIT is possible: S32K SDK Example - Function call on configurable period using LPIT timer. - NXP Community.

However, I haven't seen an example for the S32K which implements the time for a button pressed. There are some examples implemented for the KW45EVB (kw45b41zevk_temperature_collector_freertos), which implement the fsl_component_button driver, including the different types of button events, measured by time thresholds with SW timer in FreeRTOS:

/*! @brief The event type of button */
typedef enum _button_event
{
    kBUTTON_EventOneClick = 0x01U, /*!< One click with short time, the duration of key down and key up is less than
                                      #BUTTON_SHORT_PRESS_THRESHOLD. */
    kBUTTON_EventDoubleClick,      /*!< Double click with short time, the duration of key down and key up is less than
                                      #BUTTON_SHORT_PRESS_THRESHOLD.      And the duration of the two button actions does not
                                      exceed #BUTTON_DOUBLE_CLICK_THRESHOLD. */
    kBUTTON_EventShortPress,       /*!< Press with short time, the duration of key down and key up is no less than
                                      #BUTTON_SHORT_PRESS_THRESHOLD       and less than #BUTTON_LONG_PRESS_THRESHOLD. */
    kBUTTON_EventLongPress,        /*!< Press with long time, the duration of key down and key up is no less than
                                      #BUTTON_LONG_PRESS_THRESHOLD. */
    kBUTTON_EventError,            /*!< Error event if the button actions cannot be identified. */
} button_event_t;

This, however, is implemented in the KW45EVB and MCUXpresso, just for you information in case you find it useful. You can implement parts of this example into the first ones I shared.

Best regards,
Julián

0 Kudos