internal osc question

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
richardb
Posts: 310
Joined: Tue Oct 03, 2006 8:54 pm

internal osc question

Post by richardb » Sun Feb 11, 2007 5:17 pm

Is there a specific way to setup the 8mhz internal osc on a pic18f1320?
i've used Config osc = INTIO2

then added
OSCCON = %01110110 as soon as i can in the program but it takes 30 seconds to start working .

any ideas?

PS


Would it be a good idea to add some more topics like a general PIC one.
Hmmm..

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sun Feb 11, 2007 7:39 pm

To ensure code gets executed first, just use a module. For example, create a module called 'io.bas' and place in your 'UserLibrary' folder...

Code: Select all

// IO module
module IO

config osc = INTIO2
OSCCON = %01110110 
Here is a sample program...

Code: Select all

device = 18F1320
clock = 8
include "io.bas"
include "USART.bas"
include "EEPROM.bas"
include "Convert.bas"

SetBaudrate(br19200)
Write("Program starting...",13,10)
while true
   Write("High",13,10)
   delayms(500)
   Write("Low",13,10)
   delayms(500)
wend  
I programmed the above sample code onto a 18F1320 using a melabs USB programmer and it started to execute immediately on reset.

richardb
Posts: 310
Joined: Tue Oct 03, 2006 8:54 pm

Post by richardb » Mon Feb 12, 2007 12:15 pm

Thanks I'll try it tonight
Hmmm..

richardb
Posts: 310
Joined: Tue Oct 03, 2006 8:54 pm

Post by richardb » Tue Feb 13, 2007 9:25 pm

thanks agin works perfectly
Hmmm..

richardb
Posts: 310
Joined: Tue Oct 03, 2006 8:54 pm

internal osc with bootloader

Post by richardb » Thu Feb 22, 2007 9:54 am

Does anyone know if the tolerance on the internal oscillator on a pic is good enough to to use with a boot loader?
Hmmm..

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Thu Feb 22, 2007 10:09 am

It can work, but I don't supply loader firmware using internal OSC because reliability is influenced too much by environmental factors.

richardb
Posts: 310
Joined: Tue Oct 03, 2006 8:54 pm

Thanks

Post by richardb » Thu Feb 22, 2007 10:28 pm

ok i was wondering as it stated the osc is calibrated to 1% but i couldnt see what temp range that was for .
Hmmm..

Post Reply