rz/a1h timer

hello friends,

i'm working on rz/a1h microprocessor in e2studio i want to on/off Led using timers i have configured GPIO pins but i am not getting how to use timers plz anyone can u share sample code of timer or plz give me some suggestions

 

 

 

Thank you

  • Could you let me know the board you are using and the project you are referring?
    And which project do you want?
    - A hander is called at regular intervals by timer, and in the handler, LED is modified by switching GPIO output.
    - LED is modified automatically using PWM output.
  • In reply to hagiryo:

    Dear sir,
    Thanks for your reply i am using renesas rz/a1h(R7S721000VC )Board i have configured p7_10, p7_11, p7_12, p7_13 and i'm making it off/on, now i want to use timer to on/off LED for certain ms ON and for certain ms OFF plz help me with this sir it will really help me a lot


    Thanks
  • In reply to mahesh:

    i'am not getting how to write timer code to on/off Led for certain ms ON and OFF
  • In reply to mahesh:

    Hello, mahesh.
    Are you using "Renesas Starter Kit+ for RZ/A1H" board?

    Renesas Starter Kit+ for RZ/A1H:
    www.renesas.com/.../renesas-starter-kitplus-for-rz-a1h.html

    If yes, you can control LED0 via P7_1. And you can refer RZ_A1H_Tutorial_RSK project in the package can be downloaded from the following URL:
    www.renesas.com/.../D6000665.html
  • In reply to hagiryo:

    yes sir Thank you very much i will check it out and let u know

    Thanks ,
  • In reply to hagiryo:

    Hello sir,sorry to interrupt again sir i have used the same example (RZ_A1H_Tutorial_RSK) to configure gpio pins,but i found that in one example code i.e (RZ_A1H_MTU2_RSK) they are using MTU2(Multi timer function unit 2)to contol LCD
    not LED sir plz help me with this is there any eg code in which they are using normal timer function


    Thanks
  • In reply to mahesh:

    sir please reply

    Thanks
  • In reply to mahesh:

    The tutorial sample of RSK+RZA1H uses OS timer to flash the LED.
    www.renesas.com/.../D6000665.html
  • In reply to mahesh:

    Hi mahesh,

    Could you overwrite following files to RZ_A1H_MTU2_RSK?

    LED1 will be controlled using MTU2 ch0. It will changes duty of LED1 gradually.

    Do you want to use PWM function?

    RZ_A1H_MTU2_RSK.zip

  • In reply to hagiryo:

    Dear sir,
    Thank you so much sir,
    yes sir I will overwrite the following changes, sir should i call LED function in main? , what changes should i make in main function sir or where should i call the Led function sir plz let me know sir

    Thank you
  • In reply to FrankL:

    Thank you sir for your response
  • In reply to mahesh:

    Hi, mahesh,

    If you use PWM (Pulse Width Modulation) output function, you do not need to call the function to control LED.
    MTU2 has some functions:
    - Interval timer : counts configured period, for example every 1ms. OSTM also has this function.
    - PWM: outputs many pulses, we can modify the duty (the period of signal low/high) of these pulses.

    I recommend to modify RZ_A1H_Tutorial_RSK.
    In this sample program, Sample_OSTM0_Interrupt() at main.c(302) is called every 500ms.
    LED is controlled in Sample_OSTM0_Interrupt().
    The period of calling Sample_OSTM0_Interrupt() is specified by 3rd argument of R_OSTM_Init(). In this program, 500ms is specified at main.c(191).
    If you want to use this function in general, please specify the period to 1ms and increment or decrement a counter variable at the function to measure the time.
  • In reply to hagiryo:

    Dear sir

    Thank you very much i'm really learning so much I will check it out now and let you know.

    Thank you
  • In reply to hagiryo:

    Dear Sir,
    i have tried the above example( RZ_A1H_Tutorial_Rsk) but its not woking i.e LED is not toggling for 500ms
    and my main.c function is this

    int main(void) {


    init_switches();

    /* Initialise direct connected LED */
    R_LED_Init();

    // flashled();

    /* Initialise OS timer (channel 0) */
    R_OSTM_Init(DEVDRV_CH_0, OSTM_MODE_INTERVAL, 500);

    /* Start OS timer (channel 0) */
    R_OSTM_Open(DEVDRV_CH_0);


    }

    flashled(); function is working fine, it blinks LED for 200 times until switch is pressed


    please help me with this sir it will be very helpfull for me


    Thanks
  • In reply to mahesh:

    Hello, mahesh.

    > but its not working
    I suppose main function had just ended.

    You may need to place an eternal loop at the bottom of main to keep running.
    e.g.

    main
    {
        ....
        R_OSTM_Open(...);

        for(;;);
    }