View previous topic :: View next topic |
Author |
Message |
Joseph88
Joined: 14 Aug 2006 Posts: 17
|
Trouble with 18f452 internal osc and RS232 |
Posted: Tue Dec 19, 2006 12:07 pm |
|
|
Hello gurus,
I'm having trouble with my 18f452 on a picdem 2 board and rs232 communications. It will communicate properly if I have an EXTERNAL oscillator installed, but if I switch to the internal oscillator, the data received in the terminal is jibberish. Any help would be greatly appreciated.
Here is the code i'm using:
#include <18F452.h>
#fuses NOWDT,NOPROTECT,NOLVP
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, PARITY=N)
setup_oscillator(OSC_8MHZ);
void main() {
while(true){
printf("HELLO");
output_high(PIN_B3);
delay_ms(100);
output_low(PIN_B3);
}
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Dec 19, 2006 12:38 pm |
|
|
Quote: |
I'm having trouble with my 18f452 on a picdem 2 board
if I switch to the internal oscillator
setup_oscillator(OSC_8MHZ); |
The 18F452 doesn't have an internal oscillator. The 18F452.H file
doesn't have the OSC_8MHZ constant in it. It only has these two constants:
Quote: |
// Constants used in setup_oscillator() are:
#define OSC_TIMER1 1
#define OSC_NORMAL 0 |
|
|
|
Joseph88
Joined: 14 Aug 2006 Posts: 17
|
|
Posted: Tue Dec 19, 2006 12:43 pm |
|
|
HI PCM, thanks for your reply.
I'm fairly new to PIC programming, and i'm really confused about this issue. I believe the 18f452 does have an internal oscillator as the datasheets indicate that it does. With my current setup without a crystal, I can get the LED's to blink on and off on the PICDEM 2 board.
I've tried to use: setup_oscillator(OSC_NORMAL) and osc_timer1 but unsuccesful in communicating via RS232.
Any ideas?
Thanks in advance,
Joe |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Dec 19, 2006 1:00 pm |
|
|
Quote: |
I believe the 18f452 does have an internal oscillator as the datasheets
indicate that it does. |
Download the latest 18F452 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39564c.pdf
Look in section 2.1, which lists the following Oscillator Types:
Quote: |
1. LP -- Low Power Crystal
2. XT -- Crystal/Resonator
3. HS -- High Speed Crystal/Resonator
4. HS + PLL -- High Speed Crystal/Resonator with PLL enabled
5. RC -- External Resistor/Capacitor
6. RCIO -- External Resistor/Capacitor with I/O pin enabled
7. EC -- External Clock
8. ECIO -- External Clock with I/O pin enabled |
Do you see anything that says there is an internal oscillator ? |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
|
Joseph88
Joined: 14 Aug 2006 Posts: 17
|
|
Posted: Tue Dec 19, 2006 1:17 pm |
|
|
Ah crap, i'm a newb. I've been looking at the 18f4520 datasheet, not the 18f452.
Thanks guys. |
|
|
|