CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Trouble with 18f452 internal osc and RS232

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Joseph88



Joined: 14 Aug 2006
Posts: 17

View user's profile Send private message

Trouble with 18f452 internal osc and RS232
PostPosted: Tue Dec 19, 2006 12:07 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 12:38 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 12:43 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 1:00 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Tue Dec 19, 2006 1:03 pm     Reply with quote

I bet you have an external you don't know about.
check Y2 and Y1 page 54
http://ww1.microchip.com/downloads/en/DeviceDoc/30374d.pdf
Joseph88



Joined: 14 Aug 2006
Posts: 17

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 1:17 pm     Reply with quote

Ah crap, i'm a newb. I've been looking at the 18f4520 datasheet, not the 18f452.

Thanks guys.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group