Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Real Basic Question pic microcontrollers

Status
Not open for further replies.

Miltaridis

Newbie level 6
Newbie level 6
Joined
May 21, 2011
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Xanthi GR
Activity points
1,378
I am using a 18f4550 pic and i micro c pro. I have a digital waveform coming out of a flip-flop circuit and i want to be able to measure it in one of pic's digital inputs. How can i do this:lol:?
Moreover if someone could kindly explain.
How is the waveform's clock found ?
What must the frequency of the waveform be?

Thank you in advance :)
 

Hi,

You use the CCP module of the Pic, plenty of tutoriuals and examples in Micro C in the forum and web

- - - Updated - - -

Hi,

You use the CCP module of the Pic, plenty of tutoriuals and examples in Micro C in the forum and web
 
Well really appreciate your help and time. But i rather feel confused from all these information without an easy example.

What is the use of the digital inputs if you need to use ccp module ?

Cant i feed a digital signal with known frequency into a digital input ?

I see that some pins have an interrupt on change register. Can this be used to identify a waveform?

If anyone could kindly elaborate a bit more on this i would be gratefull.

Thanks in advance
 
Last edited:

Hi,

That ccp module does explain things but not always clearly for a beginner.

You do feed the signal into a digital input, but you have to have a reference timer / a counter to the number of machine cycles for your signal to run against, its the only way you can determine the length of the pulse.

I don't do Mikro C but if you google on 'ccp tutorial in mikro C' it returns a lot of entries including many posts in the eda forum.
https://www.mikroe.com/forum/viewtopic.php?t=7025
https://www.edaboard.com/threads/261765/
https://www.microchip.com/forums/m478237.aspx
 
You could make a simple frequencimeter with the microcontroller.

Using the 16f877A as example:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[CODE]
//Using 20MHz clock
#include <16F877.h>
#use delay(clock=20M)
 
boolean a;
int32 rise, rise2, value;
float freq, period;
 
#int_ccp1
void isr2()
{
  rise=CCP_1; 
} 
 
#int_ccp2
void isr()
{
  rise2 = CCP_2;
  value = rise2 - rise;
  a=1;
} 
void main()
{
   #priority ccp2,ccp1
   setup_ccp1(CCP_CAPTURE_RE); // Configure CCP1 to capture rise
   setup_ccp2(CCP_CAPTURE_RE); // Configure CCP2 to capture rise
   setup_ccp2(CCP_CAPTURE_DIV_4);
   setup_timer_1(T1_INTERNAL); // Start timer 1
   enable_interrupts(INT_CCP2); // Setup interrupt on falling edge
  enable_interrupts(INT_CCP1); // Setup interrupt on falling edge
  enable_interrupts(GLOBAL);
  a=0;
  while(TRUE) 
  {
    if(a==1)
    {
      period=value/5; //Doesn't need to divide if 4MHz
      if(period<1000)
      {
        freq=1000000/period;
        freq=freq/1000;
      }
      else
      {
        freq=1000000/period;
      }
 
      a=0;
    } 
  }
}
[/CODE]

 
Thanx for the insight .

I am thinking on using the interrupt on change feature on port B of pic18f4550 .

Will get back to you when need arise8:-D
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top