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.

Interrupt for UART via MikroC

Status
Not open for further replies.

Vizier87

Active Member
Hi guys,

I've started with configuring a lot of functions with my newly built remote which consists of keypads and an Xbee module with a 877A.

My transmitter goes on like this:

C:
 if (plus==1){
       txreg=0xbf;
     }

     if (Enter==1){
       txreg=0xca;
     }

     else txreg=0;

I've successfully received data at my receiver, a 18F4620, in which I only did it like this:

C:
if (rcif==1){
  portd=rcreg;
}

And portd lights up accordingly.

However, if I try to perform more actions within a certain value of the rcreg, like this:

C:
if (rcreg==0xAA){
  portd=~portd;
  Delay_ms(1000);
}

So basically, I'd like to make the receiver blink as long as it's receiving data. Now, that didn't work smoothly. Always I get it without getting out of the loop when my transmitter is not transmitting anything.

So my friend told me I need to use interrupt on this one. The thing is, I just don't know how to use it for this purpose. I still don't understand interrupts on this case.

Hope anyone can give me an example.

Thanks.
Vizier87
 
You use a timer and let it tick off the delay and set event to toggle the portd
 
You use a timer and let it tick off the delay and set event to toggle the portd

Have a look at this **broken link removed**

I don't what happen here two post for one lol
 
Last edited:
Thanks Burt.

you see, it's not only just toggling pins or anything like that. It's just that I need it to perform a function as long as a data is received. It has a sort of a discontinuity of the data when I measured the output at a scope.

Let's say I send 0xAE.

So receiver program:
C:
 if (rcif==1){
   buffer=rcreg;
     if (buffer==0xAE){
        rd5_bit=1;
     }
  else rd5_bit=0;
}
I'm not sure if that's the right way to do it though. Any corrections?

So anyway, when I measure the data using a scope, as long as I'm pushing the button which sends the data 0xAE, the received data is not continuous at all. There is a PWM effect, and the LED lights up dimly.

Thanks for the help.
Vizier87
 
Status
Not open for further replies.

Latest threads

Back
Top