PWM output from I/O ports

Hello All,

I am using FPB-RA4E1 board with FSP v4.2. I know that I can enable GPT output pins but I am trying to get a PWM output from a different pin (P015). I used the GPT module and set up a periodic timer with 1MHZ. During the callback function I toggle the output pin. Though I should get a 500kHz output the maximum value I saw is 360kHz. Is there a maximum limit to frequency of I/O pins? What is the reason for not getting the frequency I want?

Thanks 

İrem

Parents
  • Let me share some more information on the interrupt handling process of FSP.

    First the 'gpt_counter_overflow_isr' is called. This function calls then 'r_gpt_call_callback' and then the user defined callback function will be called. In the user defined callback function the pin write function is called to write the pin.

    So all these commands must be executed from the moment that the interrupt occurs until the pin is written.

    A way to improve this is to declare an overflow ISR and not use the FSP callback method. The code for interrupt handling will be significantly reduced.

    Then we can improve the pin toggling process by not calling 'R_IOPORT_PinWrite' but using register access to write the pin.

        R_PORT0->PCNTR3_b.POSR = 0x8000; // Set P015 high
        R_PORT0->PCNTR3_b.PORR = 0x8000; // Set P015 low

    I hope it helps.

    Regards

    AZ

Reply
  • Let me share some more information on the interrupt handling process of FSP.

    First the 'gpt_counter_overflow_isr' is called. This function calls then 'r_gpt_call_callback' and then the user defined callback function will be called. In the user defined callback function the pin write function is called to write the pin.

    So all these commands must be executed from the moment that the interrupt occurs until the pin is written.

    A way to improve this is to declare an overflow ISR and not use the FSP callback method. The code for interrupt handling will be significantly reduced.

    Then we can improve the pin toggling process by not calling 'R_IOPORT_PinWrite' but using register access to write the pin.

        R_PORT0->PCNTR3_b.POSR = 0x8000; // Set P015 high
        R_PORT0->PCNTR3_b.PORR = 0x8000; // Set P015 low

    I hope it helps.

    Regards

    AZ

Children
No Data