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

Will Changing of Crystal value effect the circuit?

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



Joined: 27 Nov 2005
Posts: 29

View user's profile Send private message MSN Messenger

Will Changing of Crystal value effect the circuit?
PostPosted: Tue Jul 04, 2006 8:35 am     Reply with quote

is there a need to change anything if i change the crystal value from 20Mhz to 30Mhz? to my circuit? will that effect the accuracy of voltage reading?

Code:
#include <18F452.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)//< change to 30Mhz crystal
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,ERRORS)
#include <lCD420.c>

void main() {
long int result;
long int result2;
float adcresult;
float adcresult2;
lcd_init();
SETUP_ADC_PORTS(AN0_AN1_VSS_VREF);
setup_adc(ADC_CLOCK_DIV_8);


while (TRUE) {


      lcd_gotoxy(1,1);                     //see note about this bit below
      printf(lcd_putc, ">>ADC<<");

     
      {
      set_adc_channel(0);
      delay_us(20);
      result = read_adc();
      adcresult = 0.0;
      adcresult = (float)result * (5.0/1024.0);
      adcresult = adcresult*(1.0);
      lcd_gotoxy(1,3);
      printf(lcd_putc, "ADC (V): %5.3fV", adcresult);
      }

      {               
      set_adc_channel(1);
      delay_us(20);
      result2 = read_adc();
      adcresult2 = 0.0;
      adcresult2 = (float)result2 * (3.0/1024.0);
      adcresult2 = (adcresult2 /1000.0) * (1000.0);
      lcd_gotoxy(1,2);
      printf(lcd_putc, "ADC (I): %5.2fA", adcresult2);
      }
}
}


Last edited by crushneck on Tue Jul 04, 2006 8:46 am; edited 2 times in total
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Jul 04, 2006 8:42 am     Reply with quote

First of all, the original configuration is 20MHz not 20KHz. I assume you meant can you change to 30MHz and the answer is no you cannot. The maximum crystal frequency supported by the PIC18F452 is 20MHz.

You can get up to 40MHz by using the internal PLL x 4 multiplier. To get 30MHz you would use a 7.5MHz crystal and set the fuse for H4 instead of HS. Similarly to operate at 40MHz you would use a 10MHz crystal and the H4 fuse.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
crushneck



Joined: 27 Nov 2005
Posts: 29

View user's profile Send private message MSN Messenger

PostPosted: Tue Jul 04, 2006 8:45 am     Reply with quote

oops sorry typo error.its not khz...i mean 20Mhz and 30Mhz
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