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.

Clock generation with PIC...help needed

Status
Not open for further replies.

uxmanz

Junior Member level 1
Joined
Nov 23, 2010
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Aeronautics Complex,Pakistan
Activity points
1,363
Ok the problem is ....i have an external clock...of 200khz....i want to generate 3 clocks out of it......100khz and other two with different duty cycle.....now the problem is with synchronization....can any body help me with this regard.....


[what i have done is generated other 3clocks....all i need is to synchronize with the the external clock......what i want to do is to edge detect the external clock with that i will sync the other 3,.......i think it would work.....i need help to edge detect:!:......]


any body with different idea, and different equipment......appreciated... ...
 

Dear friend;
On some pic it is possible to set one IO pin for external interrupt source. ie f877 has RB0 port you can select also rising or falling edge for that.
Hope it helps
 
  • Like
Reactions: uxmanz

    uxmanz

    Points: 2
    Helpful Answer Positive Rating
Hi,

Are your oscillator frequencies correct or are you using a chip with a PLL module ?

A 200khz oscillator / 4 gives a chip Clock speed of 50Khz , so given it needs 2 instructions to create a pulse, how can you generate any signal higher than 25khz?
 
  • Like
Reactions: uxmanz

    uxmanz

    Points: 2
    Helpful Answer Positive Rating
@wp100 ....actually 200k is not oscillator freq......am using 48mhz xtall,...


Code:
#include <16f877.h>
#use delay(clock=20000000)

void main(void)
{
int1 a;
int1 sw1;   //switch1 can have only binary values 0/1
sw1=input(PIN_A0);


while(a==1)
{

if((sw1)==1)
{
a=0;
}

}

while(1)
{

//int1 sw1;   //switch1 can have only binary values 0/1


output_low(pin_D0);
output_low(pin_D3);
output_high(pin_D6);
delay_us(2);


output_low(pin_D0);
output_high(pin_D3);
output_high(pin_D6);
delay_us(2);


output_high(pin_D0);
output_high(pin_D3);
output_low(pin_D6);
delay_us(2);


output_high(pin_D0);
output_high(pin_D3);
output_high(pin_D6);
delay_us(2);



}

}


this is my code.....how can i have 2.5usec delay....??
 

Hi,

If you check the datasheet you will see that 20meg is the max crystal for that chip - at 48 meg you might experience other problems
 
  • Like
Reactions: uxmanz

    uxmanz

    Points: 2
    Helpful Answer Positive Rating
Hi uxmanz;
For short term delays you can use NOP (No OPeration) which takes around 4*Tosc in PIC (Tosc is period of your oscillator). Write en empty loop something like below;
for (i=0, i<N, i++)
{};
pic will just do the increment, you can adjust delay changing value of N.
It is better to keep i as an eight bit char (since pic is 8 bit mcu)
Hope helps to you.
 
  • Like
Reactions: uxmanz

    uxmanz

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top