timer

i am using 2 gpt timer in hal layer 1timer for 1ms and 2nd one is for 1microsecond and i also use timer callback routine also..

now the thing is when i start the timer 2  for one micro second in timer 1 callback routine so my code is not work and curser goes in bsp_cfg handelr error 

  • Hi Niku-
    Have you tried not starting Timer 2 from the callback? It is best to get out of the callback quickly- perhaps by setting a flag or semaphore that can be used to start the timer from the application..

    Warren
  • In reply to WarrenM:

    yes , i tried and it will work proper.
    semaphore and that type of thing i have not much knowledge so can you give me reference code if you have base on my requirement
  • In reply to niku:

    Hi Niku-
    If you are using HAL only (No ThreadX) you could just use a global flag. A semaphore is only needed in a threaded application.

    Check out this article on semaphores if you want to learn about them.
    renesasrulz.com/.../transitioning-to-threadx-semaphores

    Warren
  • In reply to WarrenM:

    okay.
    i have doubt in timer what is the functionality in gpt timer GTIOCA AND GTIOCB PIN ?
    is it decide raising edge and falling edge or something else?
    please clear my doubt
    and one more thing i am using gpt timer and generate square wave pulse for 1 ms period but i can not able to identified my pulse genereate raising edge or falling edge how i can seen please help this two things and clear my doubt.
    thanks.
  • In reply to niku:

    niku,

    The GTIOCA and GTIOCB pins are the timer I/O pins associated to a particular GPT channel.
    For example, the S7G2 has 14 channels of GPT.
    GPT0 has pins GTIOC0A & GTIOC0B
    GPT1 has pins GTIOC1A & GTIOC1B
    GPT2 has pins GTIOC2A & GTIOC2B
    etc
    etc
    These pins can be used to output (generate) wavefroms or be used to capture (time) input waveforms.

    The GPT is a complex, but extremely powerful timer unit. Please refer to the Hardware User's Manual of the applicable Synergy device you are using for a detailed explanation of the GPT functionality. For example, if you are using an S7G2 device the Hardware Users Manual can be downloaded from:

    www.renesas.com/.../r7fs7g27h2a01cbd.html

    Please refer to 23. General PWM Timer (GPT)

    You we see that the GPT driver within the SSP has extremely limited functionality compared to what the GPT peripheral can actually do. A lot of the GPT functionality has to be achieved by you writing your own driver code. This is easily doe, but it does rely on a good understanding of the peripheral.


    You mention that you are trying to generate a 1ms square wave but cannot view the output?
    Which channel of GPT are you using?
    In the GPT timer configuration have you set the "GTIOCA Output Enabled" / "GTIOCB Output Enabled"to "True"?
    In the pin configuration tab, have you enabled the I/O pins of the corresponding GPT.
    For example, if you are using GPT0, then P511 & P512 have to be enabled in the Peripherals -> GPT -> GPT0 section

    Regards.
    Richard
  • In reply to Richard:

    thanks for replay..
    i am using custom board
    Actually I am using GPT timer in HAl DRIVER and generate square wave 1ms using pwm mode channel no 6 and GTIOCB Output is true this is my configuration according to my custom board pin and generate sqare wave one particular pin in controller and i seen sqw pulse on cro.


    but my requirement is i want to collect adc data when my square wave pulse is high period time only so i could not able to understand my squre wave pulse start at raising edge or falling edge so how i can check my pulse is start raising is or falling edge?

    and you mentioned in your answer
    "These pins can be used to output (generate) wavefroms or be used to capture (time) input waveforms. "

    my confusion is if my GTIOCA or GTIOCB pin if i select as pin level low so my square wave pulse start low to high(raising edge )
    if i select pin level is high my square wave pulse start high to low(falling edge)

    And one more thing is i used one more gpt timer 1microsecond as periodic mode in hal driver for purpose only my square wave pulse is while high only that time my 1 microsecond timer will start and collect the adc data and i use callback routine also but my two timer not synchronize proper and cursor goes internal bsp cfg error so give me some solution and please overcome to this problem

    i used external adc in my project hardware so i did not use any adc driver in code just took data and collect
  • In reply to niku:

    Niku

    I have uploaded a project (S7G2_SK_timer.zip) to the media gallery that may help. I have used GPT0 and GPT1, but the ideas can be ported to the GPT channels that you are using.

    GPT0 is generating a 1ms PWM, 50% duty.
    GPT1 is triggered from the PWM rising edge.
    GPT1 generates a 1us interrupt, handled by the callback function
    In the callback, GPT1 stops itself from counting and resets itself, waiting for the next PWM rising edge.
    PWM is on GPT0 GTIOCB0 - P511
    GPT1 callback toggles an I/O pin in the callback, P411

    I have added a Powerpoint with more explanation to the S7G2_SK_timer.zip


    Regards,
    Richard