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.

Using #INT_RB in 16F877

Status
Not open for further replies.

oguzmania

Newbie level 2
Joined
Nov 19, 2006
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Turkey-Konya
Activity points
1,303
#int_rb

Hi from Turkiye.
Firstly i am sorry for my bad English.

If I explain my project; (I use CCS C)

I have 4 equivalent sound detector circuit and then i will use op-amp in the exit of this 4 circuits.If detector detects sound op-amp (comparator) shows +5V , if not it shows 0 V.

This detector circuit's microphones are in different points.So if i send a sound signal ,the signal arrives this detectors in different times.

So I want to find this different times.(Or time differences)

Firstly i am using 16F877 and exit of comparator line combined RB<4:7>
For example;
1.detector:RB4
2.detector:RB5
3.detector:RB6
4.detector:RB7

I want to find time differences with using INT_RB and Timer1.
I set Timer 1 with using my conditions.(Example; using sound velocity etc...)

I don't want to using Timer 1 with it's interrupt.

For example this time differences;
1.detector:0 second
2.detector:120us
3.detector:2000us (2ms)
4.detector:25000us (25ms)

In my calculation i must measure 30us to 30 msn (Timer 1 64536-65536)

But i didn't make it in CCS.

I want;

if detector1 is logical1;
if (input(pin_b4))
timer 1 starts
and time1=0

if (input(pin_b5))
time2=get_timer1()

if (input(pin_b6))
time3=get_timer1()

if (input(pin_b7))
time4=get_timer1()

I want to find with time differences not using interrupt timer 1.

And when RB<4:7>pins 5V-->0V i don't want a new interrupt.

I am waiting your answers.I hope i explained my problem...

Peace be with you...

Oguz
 

int_rb ccs

Hi,
Your scheme will work if you take care of the following :

1. You should configure the RB4 to RB7 bits as input with pull up.

2. You should ensure that each bit will only change state once during a measurement cycle. This can be achieved by using four external Set/Reset Flip-Flops which could all be reset using a bit output from PIC and get set when the audio comparator outputs connected to their set inputs go low for the first time. Further changes of the comparator output will be removed by the SR FFs unless again reset by PIC.

I hope you can take care of other language specific issuues.

Regards,
Laktronics

Added after 3 hours 13 minutes:

Hi,
You should also read portB once to start with and once after every interrupt.
Regards,
Laktronics
 

    oguzmania

    Points: 2
    Helpful Answer Positive Rating
int_rb

/*************************entegreterbiyecisi@yahoo.com******************************/
int ca,ne,can,nec,change;
/***entegreterbiyecisi@yahoo.com***/
#int_rb
sensor(){
if (bit_test(port_b,7)) {ca=1;}
if (bit_test(port_b,6)) {ne=1;}
change=1;}
/***entegreterbiyecisi@yahoo.com***/
void main() {

enable_interrupts(int_rb);
/***entegreterbiyecisi@yahoo.com***/
while(true){

if(!input(dwn)){ //start
dsp_data=0;
change=false;
data_bitti=false;
output_high(role_1);
/***entegreterbiyecisi@yahoo.com***/
while(!data_bitti){
while(!change){
dsp_yaz(10);
if(!input(up)){ //stop
goto stop;}}
/***entegreterbiyecisi@yahoo.com***/
if(dsp_data<9999){
dsp_data++;
dsp_ayir(dsp_data);
change=false;
/***entegreterbiyecisi@yahoo.com***/
if(dsp_data>=role1_data){
output_low(role_1);}
if(dsp_data>role1_data){
/***entegreterbiyecisi@yahoo.com***/
data_bitti=true;
change=true;
}}}} }}
/*************************entegreterbiyecisi@yahoo.com******************************/
#fuses xt,noPROTECT,nowrt,noPUT,BROWNOUT,nolvp,WDT

//watchdog timer fuse a
WDT
void main()
set_rtcc(0);
setup_counters(RTCC_INTERNAL,WDT_2304MS);

//olarak yazılırsa 2304ms den önce
restart_wdt();
//program içinde değişik yerlere yazılmalıdır

//aksi takdirde WDT pic i reset eder
/**********www.picproje.org TURKiYE de*****************/
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top