View previous topic :: View next topic |
Author |
Message |
Guest
|
Can use the Internal RC Osc with RS-232? |
Posted: Wed Feb 13, 2008 8:01 am |
|
|
Is it possible to use the internal RC oscillator when working with RS-232. I've seen some posts on it but I'm not 100% clear whether this is an issue?
I seem to see data going out to the PC, but I'm not receiving anything in Hyperterminal.......just wondering if the internal oscillator is my issue?
Code: | #include <18F4331.h>
#device ICD=TRUE
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES EC //External clock with CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV27 //Brownout reset at 2.7V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES LVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOWINEN //WDT Timer Window Disabled
#FUSES T1LOWPOWER //Timer1 low power operation when in sleep
#FUSES HPOL_HIGH //High-Side Transistors Polarity is Active-High (PWM 1,3,5 and 7)
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES LPOL_HIGH //Low-Side Transistors Polarity is Active-High (PWM 0,2,4 and 6)
#FUSES PWMPIN //PWM outputs disabled upon Reset
#FUSES MCLR //Master Clear pin enabled
#FUSES FLTAC1 //FLTA input is multiplexed with RC1
#FUSES SSP_RC //SCK/SCL=RC5, SDA/SDI=RC4, SDO=RC7
#FUSES PWM4B5 //PWM4 output is multiplexed on RB5
#FUSES EXCLKC3 //TMR0/T5CKI external clock input is muliplexed with RC3
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,STOP=1) |
|
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Feb 13, 2008 8:36 am |
|
|
Is this for a commercial product, or just a home project?
If you check out the graphs at the end of the datasheet there are some depicting oscillator accuracy vs voltage and temperature. Generally at 5V and 25C you should be OK, but not if you stray from those conditions.
You can test your frequency either by generating an output of a certain frequency and checking it with a frequency counter, or if you don't have a counter, program a LED to blink say every 100 seconds and check it with a watch. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Guest
|
|
Posted: Wed Feb 13, 2008 8:47 am |
|
|
Should
#use delay(clock=20000000)
should it actually be 8mhz? since thats the frequency of the internal oscillator? based on the data sheet.......and hence this is the reason the serial comms is not working.......because the baud rate isn't what I think it is?
so this should be clock=8000000 ?
The board is likely to get pretty hot.......warmer than 25C
Am I better off with a Crystal? |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Feb 13, 2008 8:53 am |
|
|
The #use delay(clock=20000000) statement should match your actual clock speed. If you can, start out with a crystal. I only drop the crystal if I need to save a few pennies or a few pins. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|