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

PLL and Pic12LF1822

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



Joined: 14 Jun 2010
Posts: 16

View user's profile Send private message

PLL and Pic12LF1822
PostPosted: Wed Dec 07, 2011 10:00 am     Reply with quote

Hi,

I trying to make run my pic to 8 Mhz..... just blinking a led..

Code:

#include   <12LF1822.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES MCLR                     //Master Clear pin enabled                 

#use delay (clock=8000000)
//----------------------------------------------------------------
void main()
{
      setup_oscillator(OSC_8MHZ);
      
      for(;;)
      {
            output_high(pin_a2);
            delay_us(10);
            output_low(pin_a2);
            delay_us(10);
      }
}
//----------------------------------------------------------------


When a plug the oscilloscope on pin_a2..... the pulse is not 10us.... but 12us.....
Do you have an idea ???

thanks in advance.
joseph



Joined: 14 Jun 2010
Posts: 16

View user's profile Send private message

next....
PostPosted: Wed Dec 07, 2011 10:19 am     Reply with quote

If wrote
Code:

   for(;;)
      {
            output_high(pin_a2);
            delay_ms(10);
            output_low(pin_a2);
            delay_ms(10);
      }

.... need 10ms, I have 8us......
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 07, 2011 1:48 pm     Reply with quote

Post your CCS compiler version.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Wed Dec 07, 2011 3:44 pm     Reply with quote

It is not going to be 10uSec.
The instruction 'output_high', or output_low, itself takes four instructions to execute (so 2uSec), while the jump needed for the loop, takes three instructions to execute (one bank switch, and two for the jump itself). So you should see a high pulse of 12uSec, and a low of 13.5uSec.
All things take time....

Best Wishes
joseph



Joined: 14 Jun 2010
Posts: 16

View user's profile Send private message

PostPosted: Thu Dec 08, 2011 3:24 am     Reply with quote

my ccs version is 4.114
A problem with this version ?
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Thu Dec 08, 2011 3:59 am     Reply with quote

All software times are approximate. As the others have pointed out, all code takes time to execute. So you want reasonably precise timing you either have to count cycles precisely and turn off interrupts, or use hardware. The timers/CCPs/PWMs are the tools for this.

In practise however its rare for any timed pulse to need to be a precise time, no more, no less. Most hardware data sheets specify maximum and minimum times for critical pulses, so pulses should nto be less than 5us, or something else no longer than 100us, but these are limits; rarely are they requirements for precise times.

There are occasions when the timing is the information, such as driving servos and applications such as dimmers and motor drives. For these you should use PWMs and timers and other hardware that generates accurate and easily controlled timing, and control these by firmware. If you are intending to do a software only approach for these sorts of applications then please think again.

In general the main use of delay_xs() routines should be for short pauses (a hundred us or so at most) and timers, interrupts and flags and hardware, on or off PIC, for anything longer.

Folks have reported some problems with delay_xs() routines on some PICs with some compiler issues. If I remember correctly delay_ms() is the most commonly affected. You may have run up against that problem. Rolling Eyes

RF Developer
joseph



Joined: 14 Jun 2010
Posts: 16

View user's profile Send private message

PostPosted: Thu Dec 08, 2011 4:56 am     Reply with quote

The more recent version do best result...

1.114 to 1.120..... and no problem !
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