+ Post New Thread
Results 1 to 4 of 4
-
29th November 2019, 21:34 #1
- Join Date
- Aug 2015
- Posts
- 165
- Helped
- 7 / 7
- Points
- 1,561
- Level
- 9
[PIC] MikroC for PIC32 PIC32MZ MCU Clock Frquency [MHz] bug?
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:
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?
-
Advertisement
-
30th November 2019, 19:03 #2
Re: [PIC] MikroC for PIC32 PIC32MZ MCU Clock Frquency [MHz] bug?
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?
-
Advertisement
-
30th November 2019, 22:22 #3
- Join Date
- Aug 2015
- Posts
- 165
- Helped
- 7 / 7
- Points
- 1,561
- Level
- 9
Re: [PIC] MikroC for PIC32 PIC32MZ MCU Clock Frquency [MHz] bug?
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?
-
Advertisement
-
2nd December 2019, 16:08 #4
- Join Date
- Jul 2010
- Location
- Sweden
- Posts
- 1,021
- Helped
- 388 / 388
- Points
- 7,616
- Level
- 20
Re: [PIC] MikroC for PIC32 PIC32MZ MCU Clock Frquency [MHz] bug?
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.
+ Post New Thread
Please login