View previous topic :: View next topic |
Author |
Message |
bebeto
Joined: 18 Aug 2008 Posts: 4
|
CCP1 in 18F1320 question |
Posted: Mon Aug 18, 2008 9:21 pm |
|
|
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
|
|
|
Guest
|
|
Posted: Tue Aug 26, 2008 9:33 am |
|
|
CCP module work inconstant. I trie to measuring a square pulse and CCP value in printf is inconstant. |
|
|
Ttelmah Guest
|
|
Posted: Tue Aug 26, 2008 10:12 am |
|
|
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
|
|
Posted: Tue Aug 26, 2008 1:26 pm |
|
|
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
|
|
Posted: Tue Aug 26, 2008 2:52 pm |
|
|
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
|
|
Posted: Wed Aug 27, 2008 11:23 am |
|
|
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
|
|
Posted: Wed Aug 27, 2008 2:50 pm |
|
|
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 |
|
|
|