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)
...
set internal oscillator problem
Moderators: David Barker, Jerry Messina
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
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
-
- Registered User
- Posts: 185
- Joined: Mon Mar 10, 2008 8:20 am
- Location: Seattle, WA USA
- Contact:
Take a look at http://www.digital-diy.com. You may find some useful information there.
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