Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] MikroC for PIC32 PIC32MZ MCU Clock Frquency [MHz] bug?

Status
Not open for further replies.

K33rg4t3

Full Member level 3
Joined
Aug 2, 2015
Messages
165
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Activity points
2,607
hey
I have a simple setup with P32MZ2048EFH144
It has no external oscillator.
I have a simple code with Delay_ms(1000) which appears to work fine (the led blinks at about 1 second)
But....
I think there is something I dont understand.
Take a look:
p32bitsconfig.png
No matter what I set in "MCU Clock Frequency [MHz]", the blinking time is always the same.
I can set frequency to 200MHz or to 0.1MHz, but it seems that mikroC is ignoring this field.
It's not blinking slower nor faster when I change it.

My question is - why?
I remember that for pic18f I had to enter a correct frequency to this field for delay_ms to work (I had to respect the oscillator settings, the PLL multipler, etc).
Is this a mikroC PRO for PIC32 bug or why is it?
 

Whatever be the Oscillator frequency the Delay_ms(1) function is coded to generate 1ms delay and Delay_us(1) to generate 1us. Doesn't the function name tell that it is for a millisecond delay?
 

Whatever be the Oscillator frequency the Delay_ms(1) function is coded to generate 1ms delay and Delay_us(1) to generate 1us. Doesn't the function name tell that it is for a millisecond delay?

Did you ever use MikroC?

Delay_ms(1) doesn't magically know how long the microsecond takes. In all PIC18F, PIC16F, PIC32MX, and dsPIC, this function is taking the "MCU Clock Frequency [MHz]" from Project Settings and it calculates the proper delay based on that.

I have experienced it many times in PIC16F, that when you enter incorrect 'MCU Clock Frequency [MHz]" it blinks too fast or too slow.

And my question is - what did they change specifally for PIC32MZ? How do I configure the internal oscillator corrcetly for PIC32MZ?
 

Look in the compiler manual. Some delay functions are based on the "oscillator frequency" and some other delay functions are based on the "MCU clock".
Delay_ms is based on "oscillator frequency", so it isn't surprising that the delay doesn't change when you modify the "MCU clock" setting.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top