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 CCS Technical Support

18F2450 running slow

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



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

18F2450 running slow
PostPosted: Mon Jun 07, 2010 5:00 am     Reply with quote

Hello,

I am using the 18F2450 with the internal oscillator...
And when I toggle an output in it runs very slow.
I think I have mashed something up with the oscillator settings but have no idea what......
Code:
Code:


void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_oscillator(OSC_INTRC);
   while(1)
   {
      delay_ms(1);
   output_high(PIN_C0);
   delay_ms(1);
   output_low(PIN_C0);
   }
}

Header file:
Code:

#include <18F2450.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC                    //Internal RC Osc
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES BORV20                   //Brownout reset at 4.3V
#FUSES NOPUT                      //Power Up Timer
#FUSES NOVREGEN                 //USB voltage regulator disabled
#FUSES NOSTVREN                   //Stack full/underflow will cause reset
#FUSES DEBUG                    //Debug mode for use with ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOLPT1OSC                  //Timer1 configured for low-power operation

#use delay(clock= 8000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)


Anybody an idea??
PIC is running a factor of 500 too slow.....

Regards,
Jody
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 10:41 am     Reply with quote

Try a more simple program that blinks an LED once per second.

If it doesn't work, then post your compiler version, Vdd voltage for the
PIC, and post if you have all the required external connections such as
the MCLR pull-up resistor. Also post if you are testing this in hardware
or in Proteus.
Code:

#include <18F2450.h>
#fuses INTRC_IO,NOWDT,PUT,NOBROWNOUT,NOLVP
#use delay(clock=4000000)

//======================================
void main(void)
{

while(1)
   {
    delay_ms(500);
    output_high(PIN_C0);
    delay_ms(500);
    output_low(PIN_C0);
   }

}
mskala



Joined: 06 Mar 2007
Posts: 100
Location: Massachusetts, USA

View user's profile Send private message

PostPosted: Mon Jun 07, 2010 11:28 am     Reply with quote

Code:
setup_oscillator(OSC_INTRC);

on this device is going to be the 31K oscillator, I believe. So telling the
code that clock is 8000000 will be a problem.
Jody



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 07, 2010 12:46 pm     Reply with quote

mmmh I think that Mskala is right...

I will connect a oscillator to the pic to check if I can get it working any faster....

Thanks for the assistance,
I will let you know

Regards,
Jody
Jody



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

connec a 8MHz crystal
PostPosted: Tue Jun 08, 2010 2:28 am     Reply with quote

And still it is running slow.....
Anybody an idea??
Changed the fuse setting to HS for the crystal...

Regards,
Jody
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Tue Jun 08, 2010 7:10 am     Reply with quote

What do you mean it is running slow? You are trying to toggle the pin every ms, are you looking at it with a scope? You are not going to see anything with your bare eyes.

Did you try PCM Programmer's program? It toggles the output every 1/2 a second.
mskala



Joined: 06 Mar 2007
Posts: 100
Location: Massachusetts, USA

View user's profile Send private message

PostPosted: Tue Jun 08, 2010 12:16 pm     Reply with quote

I agree you should run his program, but unless I read the data sheet
wrong you will need to change the clock=4000000 to clock=31000.

Fuse HS won't affect the internal oscillator.
And your initial statement that it is running 500 times too slow is a
clue. 8000000 / 500 = 16000, and I think you may have forgot your
toggle factor, so 16000 * 2 = 32KHz.
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