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

CCP1 in 18F1320 question

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



Joined: 18 Aug 2008
Posts: 4

View user's profile Send private message MSN Messenger

CCP1 in 18F1320 question
PostPosted: Mon Aug 18, 2008 9:21 pm     Reply with quote

Hi guys, i try to use this code, but CCP1 value is inconstant.

Whats happening? I use in wrong way?

I use this code to measure frequency and start when one pulse is 2x old.
Code:
#int_ccp1
void handle_ccp1_int()
{     
 
 
   if (flag==1)
   {       
      t1=ccp_1;     
      setup_ccp1(CCP_CAPTURE_rE);
      flag=0;
      pulso++;   
     
   }else{
     
      setup_ccp1(CCP_CAPTURE_fE);
     
      if (sync==0)
     {
      if ( t1>tt+tt   )
      {
       
         sync=1;         
         pulso=1;
        }     
      }
       set_timer1(0);
       flag=1;
       pulso++;   
       tt=t1;
   }
   if (sync==1) Mapa();
 
}


(...)

setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);

setup_ccp1(CCP_CAPTURE_RE);         
clear_interrupt(INT_CCP1);
enable_interrupts(int_ccp1);
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 19, 2008 1:56 pm     Reply with quote

Read these threads on how to use the CCP to measure frequency:
http://www.ccsinfo.com/forum/viewtopic.php?t=29963
http://www.ccsinfo.com/forum/viewtopic.php?t=33153
Guest








PostPosted: Tue Aug 26, 2008 9:33 am     Reply with quote

CCP module work inconstant. I trie to measuring a square pulse and CCP value in printf is inconstant.
Ttelmah
Guest







PostPosted: Tue Aug 26, 2008 10:12 am     Reply with quote

The CCP works.
Plenty of people have used it with no problems.
Likeliest thing to cause trouble, is the signal levels. The CCP, uses a _Schmitt_ input, which requires the input to go up to 0.8* the supply voltage, and down to 0.2* the supply. The latter is not a problem, but the former is higher, than is guaranteed by things like a 'normal' TTL output. If your signal is not reliably doing this, then you will get erratic behaviour.

Best Wishes
bebeto



Joined: 18 Aug 2008
Posts: 4

View user's profile Send private message MSN Messenger

PostPosted: Tue Aug 26, 2008 1:26 pm     Reply with quote




the input signal level.

I make some measuring to check signal level and dont find problem.

If i run program in proteus all work fine, but if i write in pic and run the measuring results is diferent.

timer 0 didn't work wwith have ccp (timer1) process?
Ttemah
Guest







PostPosted: Tue Aug 26, 2008 2:52 pm     Reply with quote

How to not show useful data....
You don't show what the zero volt level is. If B is the zero level (which is what the graph looks like), then it looks as if this signal is swinging to something like +2v, and -2.5v. This will never work. You would need to connect it's ground to a voltage of about 2.5v...
I'd suspect this is where your problem lies.

Best Wishes
bebeto



Joined: 18 Aug 2008
Posts: 4

View user's profile Send private message MSN Messenger

PostPosted: Wed Aug 27, 2008 11:23 am     Reply with quote



Ttemah

Channel 1 as 16f628 output to 18f1320 input.

Channel 2 is a 3ms 18f1320 output.


Time hight in channel 1 is 200us.
Ttelmah
Guest







PostPosted: Wed Aug 27, 2008 2:50 pm     Reply with quote

The channel two display, shows the channel reference level near the _bottom_ of the waveform. The channel one display, shows the reference level in the _middle_ of the waveform. Then channel 2, is shown as having a unit amplitude of 50v, not 5v. Suggests you have the scope set for *10 probes, and the probe set to *1, otherwise how can the logic output from the chip give such an amplitude?...
Set both probes to *10, make sure the scope is set to use *10 probes, set the vertical scale to 5v, and set the cursor level to 0v, then we can see what the waveforms actually represent.
So far, the information is still useless.

Best Wishes
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