18f4520 internal osc not running at 8Mhz with microBasic PRO

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
isakhen
Posts: 2
Joined: 17 Dec 2009 14:36
Location: South Africa

18f4520 internal osc not running at 8Mhz with microBasic PRO

#1 Post by isakhen » 17 Dec 2009 14:58

In microBasic PRO, I selectet new project, selected 18f4520, set project settings 8Mhz, in Edit Project selected "INT RC-CLKOUT on RA6,Port on RA7". The freq to read at RA6 is the feq used devided by 4 and I get 250hz, that is the pic runs at 1Mhz.

If I add the following in Main
OSCCON.B6 = 1
OSCCON.B5 = 1
OSCCON.B4 = 1
I get 2Mhz at A6, that is 8Mhz devided by 4
( OSCCON settings from page 32 on Data Sheet of Pic)

Did I miss something in Edit Project or are the config word send to PIC by
microBasic PRO wrong?

This OSCCON register workaround did take quite a bit of time for me and a lot of reading in the datasheets

rmteo
Posts: 1330
Joined: 19 Oct 2006 17:46
Location: Colorado, USA

#2 Post by rmteo » 17 Dec 2009 16:48

Bits 6-4 (IRCF2:IRCF0: Internal Oscillator Frequency Select bits) of the OSCCON register set the frequency - 1Mhz is the default. What you did is correct. Edit Project only sets the config bits of the MCU - see Section 23 of the data sheet (CONFIG1H register).
Why pay for overpriced toys when you can have
professional grade tools for FREE!!! :D :D :D

isakhen
Posts: 2
Joined: 17 Dec 2009 14:36
Location: South Africa

#3 Post by isakhen » 18 Dec 2009 07:58

Thanks rmteo

But I still found it a bit misleading in that the Freq. set in Project Settings is only used to determine the correct timing for the basic routines.
Someone without a Freq. meter and less problem solving skills will not have solved it so easily.
[/quote]
Isak Hendrikse

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

#4 Post by anikolic » 21 Dec 2009 10:24

Hi,
You should consider MCU frequency setting as a place where you can tell the compiler what frequency you are going to use in your project, so when it does internal calculations for Delays and baud rates and other settings, it can do it precisely. Lots of calculations in PIC compilers are done by IDE, so you wouldn't waste your precious RAM on these devices due to memory and stack restrictions.

Best regards,
Aleksandar
Web Department Manager

Post Reply

Return to “mikroBasic PRO for PIC General”