set internal oscillator problem

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Luciano
Posts: 13
Joined: Fri Feb 12, 2010 2:00 pm

set internal oscillator problem

Post by Luciano » Tue Jul 06, 2010 11:37 am

Hi, I am trying to set up an internal oscillator at 8MHz using a separate module as suggested, but can't get it working in connection with the USART (I am adapting a previosuly working program written in another language). could you please send some suggestion?
many thanks in advance
Luciano

this is the module:

Module Intosc
Config OSC = INTIO67 'using INTIO7 do not seem to make any difference
Config MCLRE = off ' with or without this instruction makes no difference
OSCCON = %01110110

this is the main program:

Device = 18F4525
Clock = 8

#option USART_BRGH = true
#option USART_BRGH16 = true

Include "intosc.bas"
Include "USART.bas"
Include "Convert.bas"
Include "ADC.bas"
...
delayms(1000)
USART.SetBaudrate(br115200)
...

Luciano
Posts: 13
Joined: Fri Feb 12, 2010 2:00 pm

Post by Luciano » Wed Jul 07, 2010 8:43 am

I contunue to have weird results:

I tried to receive one byte and this is the result I get (unfortunately I cannot use a display but just count ho many times a LED blinks :?

if I send 1 to 15 I correctly receive 1 to 15
if I send 16 I then receive 48
if I send 55 I then receive 119

(ie seems that the UART is setting 1 bit higher than the data if the data exceeds 4 bits)

all this seems to suggest that the USART is not correctly set for some reason, but I do not have an oscilloscope available at the moment to check the clock correctly. on the other hand, the rest of the program seems to work.

I hope to get some suggestion
many thanks in advance
Luciano

Luciano
Posts: 13
Joined: Fri Feb 12, 2010 2:00 pm

Post by Luciano » Mon Jul 12, 2010 8:35 am

unfortunately I am stuck with this problem.
I am sure many people have used the USART with the internal oscillator and a module, but I could not find any example in the forum to compare to my code.
I hope some one can give a suggestion
many thanks in advance
Luciano

Jon Chandler
Registered User
Registered User
Posts: 185
Joined: Mon Mar 10, 2008 8:20 am
Location: Seattle, WA USA
Contact:

Post by Jon Chandler » Mon Jul 12, 2010 4:34 pm

Take a look at http://www.digital-diy.com. You may find some useful information there.

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Sat Jul 17, 2010 3:37 am

Maybe its calling it wrong The internal osc register is INTOSC. This is from the data sheet
2.6.1 INTIO MODES
Using the internal oscillator as the clock source
eliminates the need for up to two external oscillator
pins, which can then be used for digital I/O. Two distinct
configurations are available:
• In INTIO1 mode, the OSC2 pin outputs FOSC/4,
while OSC1 functions as RA7 for digital input and
output.
• In INTIO2 mode, OSC1 functions as RA7 and
OSC2 functions as RA6, both for digital input and
output.
2.6.2 INTOSC OUTPUT FREQUENCY
The internal oscillator block is calibrated at the factory
to produce an INTOSC output frequency of 8.0 MHz.
The INTRC oscillator operates independently of the
INTOSC source. Any changes in INTOSC across
voltage and temperature are not necessarily reflected
by changes in INTRC and vice versa.
2.6.3

Post Reply