Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

rise and fall of the clock

Status
Not open for further replies.

hitch

New Member
hi all

working with i2c and SPI and AT Keyboards, All of these things use a clock signal for data and so on.

my problem is - I am using oshonsoft pic basic, how do i check for a "falling" edge clock signal or a "rising" edge clock signal , i am not an electronic engineer so maybe i am not "understanding" the terms properly. I do grasp the obvious that rising edge is when the signal goes from 0v - 5v or what ever the voltage. So basically i understand the concept i just want to know how to code it in oshonsoft pic sim.

thanks
 
hi all

working with i2c and SPI and AT Keyboards, All of these things use a clock signal for data and so on.

my problem is - I am using oshonsoft pic basic, how do i check for a "falling" edge clock signal or a "rising" edge clock signal , i am not an electronic engineer so maybe i am not "understanding" the terms properly. I do grasp the obvious that rising edge is when the signal goes from 0v - 5v or what ever the voltage. So basically i understand the concept i just want to know how to code it in oshonsoft pic sim.

thanks
hi,
There a couple of ways, POLLING the pin to test its state or using INTERRUPTS.
PORTB.0 is a useful pin for this operation.
 
by polling you mean i use a loop and chk the state of the pin?

Code:
loop:
    if portb.0 = 1 then 
           ....code...
    end if
goto loop
[code]

is this what you mean? would this be rising edge of falling edge?
 
Polling will tell you if the pin is high (5V) or low (0V) only. If you want to detect the rising or falling edges you need to use the capture and compare element. Not familiar with oshonsoft I'm afraid.
 
at he moment i am using a pic16f84.
so i could say - if rb0 high set chflag = 1
then if rb0 = low and chflag = 1 then clock signal went back to 0 which is falling edge?
 
at he moment i am using a pic16f84.
so i could say - if rb0 high set chflag = 1
then if rb0 = low and chflag = 1 then clock signal went back to 0 which is falling edge?

hi,
To POLL an edge you have to constantly test the pin, if you want an accurate timing of the event.
Its a very inefficient way to do it, it ties up the PIC, also the edge may never happen.!!
Look at interrupts on PORTB.0, it can be set for rising or falling edges.
 

Attachments

  • AAesp02.gif
    AAesp02.gif
    16.2 KB · Views: 152
Last edited:
ihave read a few other posts and forums and basically i am on the right track, but i think i am just worried with my "version" of coding it.
If i use the INT method how would i know in what state it is in? should i initialise it myself and just set a "high" flag then if an INT occurs i can just compare it to the Flag value?
Also i know that polling seems to be a waste of PIC CPU Time but if all it is doing IS waiting for the Clock input does it matter? I can see that this would allow me to "monitor" diff inputs?. Does anyone have a code sample using oshonsoft or similar picbasic? thanks.
 
ihave read a few other posts and forums and basically i am on the right track, but i think i am just worried with my "version" of coding it.
If i use the INT method how would i know in what state it is in? should i initialise it myself and just set a "high" flag then if an INT occurs i can just compare it to the Flag value?
Also i know that polling seems to be a waste of PIC CPU Time but if all it is doing IS waiting for the Clock input does it matter? I can see that this would allow me to "monitor" diff inputs?. Does anyone have a code sample using oshonsoft or similar picbasic? thanks.

hi,
Post what you have so far and I will add to it using Oshonsoft.
I dont want to start giving examples which are not relevant to what you are trying to do, its more useful for you if I can tailor my code fragments to suit your application.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top