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