Need a sanity check here!
I've been runing on an external 20Mhz resonator ....HSEROUT worked fine.
now want to go with the PIC's 4Mhz internal oscillator (to free up a couple of pins)...but no matter what I do, HSEROUT is garbage.
I'm using MPASM... the16F690inc file has a couple of options that I'm not clear about...
_INTRC_OSC_NOCLKOUT
_INTOSC
...could someone tell me why two options that look similar? (I've tried both....but sticking with _INTRC_OSC_NOCLKOUT )
Anyway, back to my problem....
Code:
@ __CONFIG _FCMEN_OFF & _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _BOR_OFF & _PWRTE_OFF
DEFINE OSC 4 ' set Oscillator at 4Mhz.
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 HSER_SPBRG 25 ' 9600 Baud @ 4MHz, 0.16%
SPBRGH = 0
BAUDCTL.3 = 1 ' Enable 16 bit baudrate generator
Include "modedefs.bas"
ANSELH=0
ANSEL=0
CM1CON0 =0
CM2CON0 =0
CM2CON1 =0
adcon1=0
TRISB.6 = 1
TRISB.7 = 0
TRISC=%00000000 ; set all Port C pins as outputs
rcsta.7=1 'SPEN serial port enable bi
loop1:
hserout ["hello", 13, 10]
pause 250
goto loop1
end
Grateful for any input here....I'm going crazy looking at this problem for hours!
Edit: Just rolled back to the external 20Mhz resonator oscillator - Hserout works just fine - could it be the internal oscillator is out of spec & therefore wrong after being divided down?
Bookmarks