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.

[SOLVED] Using Rx interrupts on PIC16f877 to receive values from PC

Status
Not open for further replies.

dark_ph0enix

Newbie level 3
Joined
Jul 30, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Galaxy far far away
Activity points
1,302
Hi!

I'm new to the site and I come here and humbly ask for your insight :grin:

I'm programming a 16f877 from Microchip (using High-Tech compiler) and I came across a situation where I need to receive 3 values from the PC (sent by MATLab). My question, the reception can occur at anytime, so the logical ideia would be to use RX interrupt.
How can I do this? I can't seem to find examples in C for interrupts and also, any idea how i should lock the interrupt to receive those 3 values?

Thanks in advance

J
 

Re: Interrupts on 16f877

Here's a link to one of the best online PIC tutorials I've come across:

**broken link removed**


The tutorials cover both baseline and midrange PICs using Assembly and Hi-Tech C. The PIC16F877 is a midrange PIC so you'll want to concentrate on the following two sets of tutorials:

**broken link removed**

**broken link removed**

The tutorial are very professionally done, are in PDF form with downloadable source code and best of all are absolutely free.

The Midrange Hi-Tech C Tutorials begin covering Interrupts on lesson 3 and continue to introduce interrupt techniques through the remaining lessons.

Start with the tutorials and if you still have questions, just ask.

Hope they help in your endeavors.

BigDog
 

Re: Interrupts on 16f877

the best way is to refer the datasheet of PIC16f877 for configuring relevant registers. and what do you mean by lock the interrupts?
 

Re: Interrupts on 16f877

@bigdogguru Thank you, I'll looking into those tutorials =)

@nikhil_jain I've already configured the interrupts, the problem is, theres no example how to set an interrupt in actual code in the datasheet. And what I meant by locking was, once the interrupt was activated, it would remain there to receive both 3 values.

Thanks for your replies

J
 

Re: Interrupts on 16f877

Hi, I not sure about the correct synatx. But if it does not work I will send the correct syntax from my pc at work. You wouid do it like this:


unsigned char rxbuf;
unsigned char index;
bit rx_flag;

void interrupt isr (void)
{
if (RXIE & RXIF)
{
RXIF = 0;
rxbuf[index++] = RXDATA;
If (index > 3)
{
index = 0;
rx_flag = 1;
}
}
}

The above code is an example of how the interrupt works. Make sure that the registers for the usart is correctly configured, and the periperal as well as the global interrupts and the baud rate is correct. You can the service the rx_flag in your main routine

MN
 

Re: Interrupts on 16f877

Hi, I not sure about the correct synatx. But if it does not work I will send the correct syntax from my pc at work. You wouid do it like this:


unsigned char rxbuf;
unsigned char index;
bit rx_flag;

void interrupt isr (void)
{
if (RXIE & RXIF)
{
RXIF = 0;
rxbuf[index++] = RXDATA;
If (index > 3)
{
index = 0;
rx_flag = 1;
}
}
}

The above code is an example of how the interrupt works. Make sure that the registers for the usart is correctly configured, and the periperal as well as the global interrupts and the baud rate is correct. You can the service the rx_flag in your main routine

MN

i think that's it =D i'll be trying that piece of code tomorrow, i'll let you know if it works :grin: thanks in advance ^^
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top