MCU Clock

mikroC, mikroBasic and mikroPascal PRO for Microchip’s 8-bit PIC MCUs.
Post Reply
Author
Message
GunkutA
Posts: 44
Joined: 16 Jan 2019 11:56

MCU Clock

#1 Post by GunkutA » 30 Jan 2019 14:19

Hello I'm not sure about setting the clock frequency in MicroC. Normally I do it with registers but in program there is a MCU Clock frequency window in left part. Is this working? If I want 8 MHz clock for example, when I write 8 MHz in there, will it set my clock to 8 MHz? I tested it and it doeesn't look like it's working for me. Thanks

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: MCU Clock

#2 Post by janni » 30 Jan 2019 14:41

This is only information for compiler - used for software delays and communication baud rates calculations.

GunkutA
Posts: 44
Joined: 16 Jan 2019 11:56

Re: MCU Clock

#3 Post by GunkutA » 30 Jan 2019 15:11

janni wrote:This is only information for compiler - used for software delays and communication baud rates calculations.
So if I want to implement 250 kbps can bus communication, do I need to take the clock value that is in MCU clock window or the value I achieve with registers. For example: if I have a 1 MHz value in MCU Clock window and I arrange my registers for 8 MHZ internal oscillator. Which one should I consider for calculating my Can Bus timing values? 8 Mhz one or 1 Mhz one? Thanks.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: MCU Clock

#4 Post by janni » 30 Jan 2019 15:35

GunkutA wrote:For example: if I have a 1 MHz value in MCU Clock window and I arrange my registers for 8 MHZ internal oscillator. Which one should I consider for calculating my Can Bus timing values? 8 Mhz one or 1 Mhz one? Thanks.
Wrong question. One value should match the other. If you want time-dependent peripherals and delays to work correctly, you cannot lie about clock frequency :wink: . Compiler doesn't follow your clock settings and cannot know what is external crystal frequency - that's why you have to put the effective frequency in Project Settings window.

GunkutA
Posts: 44
Joined: 16 Jan 2019 11:56

Re: MCU Clock

#5 Post by GunkutA » 31 Jan 2019 07:21

Clear, thank you Janni :D

Post Reply

Return to “PIC PRO Compilers”