• AVR Freaks

Hot!verifying the MHz of the pic32mk

Author
MPaulHolmes
Junior Member
  • Total Posts : 89
  • Reward points : 0
  • Joined: 2009/10/31 10:52:40
  • Location: 0
  • Status: offline
2020/01/21 17:27:16 (permalink)
0

verifying the MHz of the pic32mk

I initialized my pic32MK chip to run at 120MHz, but when I run this in a loop:
start = _CP0_GET_COUNT();
end = start;
while (end - start < 120000000) {
end = _CP0_GET_COUNT();
}
**toggle led**
start = _CP0_GET_COUNT();
end = start;
while (end - start < 120000000) {
end = _CP0_GET_COUNT();
}
**toggle led**
 
The LED blinks 2 seconds off, 2 seconds on.  Isn't CP0_GET_COUNT() the number of cycles of the CPU?  Does this mean I made a mistake somewhere and the chip is only running at 60MHz?  Or am I misunderstanding what CP0_GET_COUNT actually is?
#1

2 Replies Related Threads

    simong123
    Lab Member No. 003
    • Total Posts : 1391
    • Reward points : 0
    • Joined: 2012/02/07 18:21:03
    • Location: Future Gadget Lab (UK Branch)
    • Status: offline
    Re: verifying the MHz of the pic32mk 2020/01/21 17:54:30 (permalink)
    4 (1)
    CP0_GET_COUNT updates at half the CPU clock rate, so you are running at 120MHz OK
    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 18901
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: verifying the MHz of the pic32mk 2020/01/21 17:56:06 (permalink)
    0
    Yes, it is half the Main Oscillator frequency.
     
    #3
    Jump to:
    © 2020 APG vNext Commercial Version 4.5