Pic32mz pin toggle speed. Need help

Thread Starter

ExtreMme

Joined Dec 26, 2019
2
Hi all. I am New on this forum. I have designed and created a pcb board with mcu pic32mz2048emf-100.
In mplab i use harmony 2 to configure speed to 200mhz. I use internal 8mhz osc. I check with my Rigol osciloscope clock speed in osc2 pin and is a 50mhz. Osc2 clock = (pbclk4)/2. And pbclk4= 1:2 sys clock. this is (200/2)/2= 50mhz. When i change pbclk4 to 1:1 then i have 100mhz clock on osc2 pin. So i Think that my config is ok and cpu run at 200mhz.

in main loop i toggle pin with LATGbits.LATG15 command. And when i check this pin on my osciloscope i get o 6-7Mhz.So i dont know why... :(
For my is too slow.

Please help me:)
 

Sensacell

Joined Jun 19, 2012
3,784
Have you looked at the machine code disassembly and counted the machine cycles it takes to complete the loop?
Until you do that, the measurement you get from the IO pin is meaningless.

The CPU instruction rate is not the clock rate, the instruction cycle takes multiple clocks to complete.

Study the datasheet, count the clock cycles in your loop, when you can accurately predict the toggle frequency of your routine, then you are understanding what is going on.
 

atferrari

Joined Jan 6, 2004
5,011
If not yet, be aware of the stopwatch used in simulation. I would resort to it, upfront. In fact, I did when starting with a new micro and MPLABx for the first time.
 

Ian Rogers

Joined Dec 12, 2012
1,136
FOSC/5 or FOSC/4, Ian?
None.... The peripheral clock serves ports and the like.... I think they can be run at sysclk / 2 speed, but why! too fast for most peripherals..

All documentation about osc options is here.. https://microchipdeveloper.com/32bit:mz-osc

Also!! If the MZ needs to be run at 200Mhz, you'll need a fpl 100x multiplier and fpl divisor of 2.. Have you a copy of the OSC settings....
 
Last edited:

atferrari

Joined Jan 6, 2004
5,011
Complex eh? But not complicated it seems.

This morning I've read summarily the family manual but could not make sense of much there. Found an Fosc/4 mentioned somewhere but then had to quit and return to daily life.

Thanks.
 
Last edited:

Ian Rogers

Joined Dec 12, 2012
1,136
The osc settings on the pic32 is...…………. Well a bit ott!!

I spent hours trying to convince a developer that a 40Mhz crystal could not be used on a pic32mx, but a 4Mhz would give every speed!!! Fog is clearer...
 
Top