2173 views|2 replies

1237

Posts

66

Resources
The OP
 

RSL10 RTE add timer [Copy link]

 

RTE (run-time environment) is a runtime environment added after MDK V5.0. It contains common peripheral drivers developed in accordance with the CMSIS Driver specification, such as GPIO, UART, I2C, SPI, USB, etc., which are called RTE drivers, that is, runtime environment drivers. RTE provides a graphical configuration method, which is very convenient to use.

The SDK provided by ON Semiconductor also provides timer routines. Here I need to add a timer to my own project to perform regular data collection.

Double-click the xx.rteconfig file to open the RTE configuration interface.

Select Timer here . If the driver depends on other components, a prompt will be given.

Next, configure the detailed parameters in the RTE_Device.h file. The writing of RTE_Device.h follows the relevant specifications of RTE. You can open it in a graphical way or edit the source file directly.

The test code is as follows, which shows that the use of CMSIS driver is very simple.


#include <app.h>
#include <RTE_Device.h>
#include <TIMER_RSLxx.h>

#if !RTE_TIMER
    #error "Please configure TIMER in RTE_Device.h"
#endif    /* if !RTE_TIMER */

/* Global variables and types */
DRIVER_TIMER_t *timer;
extern DRIVER_TIMER_t Driver_TIMER;
/* Timer 0 timeout value */
static uint32_t timeout = 0;
/* Timeout values */
#define TIMER0_BASE_TIMEOUT             0x3000
#define TIMER0_TIMEOUT_STEP             0x800

/* ----------------------------------------------------------------------------
 * Function      : void Timer_EventCallback(uint32_t event)
 * ----------------------------------------------------------------------------
 * Description   : This function is a callback registered by the function
 *                 Initialize. Based on event argument different actions are
 *                 executed.
 * Inputs        : None
 * Outputs       : None
 * Assumptions   : None
 * ------------------------------------------------------------------------- */
void Timer_EventCallback(uint32_t event)
{
    /* Check if timer0 event has been triggered */
    if (event & TIMER_TIMER0_EVENT)
    {
        PRINTF("TIMER0 TRIGGERED\n");
        return;
    }
}


int main(void)
{
    /* Configure hardware */
    Device_Initialize();


    /* Initialize timer structure */
    timer = &Driver_TIMER;
    /* Configure timer callback function */
    timer->Initialize(Timer_EventCallback);//设置定时器溢出回调函数
    timeout = TIMER0_BASE_TIMEOUT;
    timer->SetValue(TIMER_0, timeout);//设置超时值
    /* Start timer 0 (free run mode) */
    timer->Start(TIMER_0);//启动定时器
    PRINTF("STARTED TIMER0\n");

    while (1)
    {
        Sys_Watchdog_Refresh();
    }
}

Effect:

Latest reply

How many milliseconds does your timer measure?   Details Published on 2021-6-26 14:44
 
 

1942

Posts

2

Resources
2
 

How many milliseconds does your timer measure?

Comments

I haven't calculated it yet. I don't know the mechanism of the timer driver yet.  Details Published on 2021-6-29 00:38
 
 
 

1237

Posts

66

Resources
3
 
w494143467 posted on 2021-6-26 14:44 How many milliseconds does your timer measure?

I haven't calculated it yet. I don't know the mechanism of the timer driver yet.

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list