PDA

View Full Version : 18F2620 OSC Confusion



atillotson
- 24th June 2005, 23:56
Hi All,
I'm Very new here, Got my PBP 2.46 software with MCSP and Serial programmer by Melabs and have been writing some code in basic for the first time. Alot easier than Ansi C, thats for sure. Anyway, I'm really glad to be here.
Now on to my problem, I'm communicating to my 18f2620 with great success except for the fact that the speed at which I'm communicating is 2400 Baud. My intention is to be at 9600. The other unusal fact is that I have two blinking lights that Blink at a rate 4 times slower than the 500ms I have selected. So both Baud and Flashing lights are 1/4 what the should be. So i'm sure their must be an include file that i should be using but I didnt find exactly what I was looking for In the Forum. I was hoping for some guidence.

I should mention that each time i use the serial programmer it selects XT for my OSC at the top of "Configuration Screen"- (sorry dont really know the name of that screen.) If I select INTRC or INTRC Clockout it will simply change my selection before i program it.

My thought is that I need to define it or add an include file. But How.

I'm not using an RS232 chip, I'm talking Directly as it has an internal USART. so I think I should be using INV output, and I wanted to eliminate all possibilities for human error until I get some stick time with my new toys...

Any Ideas?

Ash Man

'Code:

loop:
SEROUT2 portc.6, 16468, ["Hello World!", 13,10] ' 9600, I think

High PORTB.0 ' Turn on LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds

Low PORTB.0 ' Turn off LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds

High PORTB.3 ' Turn on LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds

Low PORTB.3 ' Turn off LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds
Goto loop ' Go back to loop and blink LED forever

mister_e
- 25th June 2005, 01:41
wich crystal speed you have???

let's say 20MHZ.... So set config fuse to HS OSC at programming time and add
DEFINE OSC 20
at the top of your code

XT is for 4MHZ crystal only.

If you select INTROSC, on F2620 the default setting is...1 MHZ wich explain the 1/4 time speed you have. Default PBP xtal speed is 4MHZ.
to set internal Oscillator speed, write directly to OSCCON register.
OSCCON=%01100000 '=> set internal osc to 4MHZ
the above will fix your problem.

Be friend with this (http://ww1.microchip.com/downloads/en/DeviceDoc/39626b.pdf)

Welcome to the forum and have fun!!!

mister_e
- 25th June 2005, 01:45
ooh i forget, you can't configure the internal USART to talk directly to the PC... you need MAX232 or else inverter. BUT you can use software command like SEROUT, SEROUT2 and use the inverted mode. Just use a resistor in serie will work.

atillotson
- 28th June 2005, 01:10
Thanks, Worked Like a Dream!
Ash