Hello,

I have small project using PIC18F26K22 with 8MHz crystal external oscillator. USART output from PIC is connected over TTL to USB and I use TERMITE serial software to read data from PIC.

I wanna send numbers from 1-255 over USART with a pause of 1 sec.

From pbp manual it state that for every other external oscillator I need to use DEFINE OSC, for my example DEFINE OSC 8.

Code:
 DEFINE OSC 8

define HSER_BAUD 9600
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
define HSER2_BAUD 9600
DEFINE HSER2_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER2_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER2_CLROERR 1 ' Clear overflow automatically

ANSELC = 0


i var word
i = 0
tajmer var byte

start:
    i = i+ 1
    Hserout2 [dec i,13,10]
    pause 1000

goto start
Since pause is in millisecond this should give me 1 sec delay. But this delay last to to long over my serial terminal.

I have tried many things and find it only working if I add this line:

Code:
#config
 CONFIG FOSC = HSHP
#endconfig
When using this confing pause 1000 is really 1 sec. I think with this command I have disabled internal oscillator.

When I look deeper in datasheet it is said that HSHP is best for high power oscillator >16MHz and for oscillators used from 4MHz - 16MHz should be used HSMP.

When I used

Code:
#config
 CONFIG FOSC = HSMP
#endconfig
again my pause 1000 is not 1 sec.

Any help, advice, correction ?

Thx