Pumpkin, Inc.

Pumpkin User Forums

PIC16F877

For issues specific to Microchip's PICmicro® MCUs, including compilers (e.g. HI-TECH PICC & PICC-18, Microchip MPLAB®-C18) and IDEs (e.g. Microchip MPLAB®).

PIC16F877

Postby 1064453 » Sun Jun 25, 2006 8:03 am


Hi AEK:

Do you have sample code for using
interrupt in Pic16F877?
TQ.

1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: PIC16F877

Postby aek » Tue Jun 27, 2006 7:26 am

Look in the isr.c files in the common or SYSA subdirectories of a Salvo ditribution -- that's all PIC16 code. This code usually just calls OSTimer() via a timer.

Also look at the end of http://www.pumpkininc.com/content/doc/appnote/an-8.pdf in the listing for int.c.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: PIC16F877

Postby 1064453 » Mon Jul 31, 2006 12:36 am


Hi Aek:

I hv not yet read all and understand
all the an-8.pdf content (Implementing software UART).
But I have questions:
1. After the Start Bit Detector has
detected the start bit, then only the
TX task will be called. That is a
delay. In that case, will your
software UART TX miss out some data?
2. Do you have more focus and more easier
sample code for using interrupt in
Salvo? An8 is too complicated for
a beginner.

TQ.



1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: PIC16F877

Postby aek » Mon Jul 31, 2006 12:45 am

1. The code in AN-8 is extremely robust for 1200 baud. It does not miss start bits. Look at the code (esp. the ISRs) more carefully.

2.

quote:
Look in the isr.c files in the common or SYSA subdirectories of a Salvo ditribution -- that's all PIC16 code. This code usually just calls OSTimer() via a timer.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: PIC16F877

Postby 1064453 » Mon Jul 31, 2006 10:19 am


HI Aek:

a) The interrupt example in the tutorial 5
is a timer interrupt. And the Salvo
still have to monitor (polling) the
delayed task. Therefore, do you have
direct interrupt from the delayed task
to the Salvo?

b)In tutorial 5, How does main.c know the
existance of isr.c or call the
interrupt vector? I did not see your
tutorial include isr.c?

c) Do you hv external hardware interrupt
in Salvo? For example, when pin 1 detect
rising edge of voltage.


TQ

-



1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: PIC16F877

Postby aek » Tue Aug 01, 2006 1:37 am

1. There is no polling in Salvo. Ever. Salvo is an event-driven RTOS.

2. Interrupt vectors are never called by any portion of an application's code. They are interrupts, and are invoked by hardware events. The tutorials tu5 and tu6 include isr.c as a file in the project.

3. The Salvo examples do not include any instances of external interrupts. However, you can certainly use them ...

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: PIC16F877

Postby 1064453 » Tue Aug 01, 2006 5:02 am


Hi AEK:

2. Interrupt vectors are never called by any portion of an application's code. They are interrupts, and are invoked by hardware events. The tutorials tu5 and tu6 include isr.c as a file in the project.
---
My questions were not too clear, let
me rephrase my question.

How do tu5 and tu6 include isr.c?
I did not see #include <isr.c> in your
source code?
---
3. The Salvo examples do not include any instances of external interrupts. However, you can certainly use them ...
---
My question is <if there is external hardware interrupt, how does Salvo detect or get to know there is interrupt>?
---

4. If a task is ongoing, and the Timer periodic interrupt occurred. The current
task will be let finished first, then
only the interrupt will be processed?


-
TQ


-


1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: PIC16F877

Postby aek » Tue Aug 01, 2006 5:39 am

2. One should not normally #include C source files. Only header files (*.h) are normally included. isr.c is added to the project as a project file / node in the MPLAB project.

If you open the example MPLAB project, you'll see that isr.c is one of the nodes, along with main.c.

Perhaps what is confusing you is that it is often the case that an application will build successfully even if you forget to add the ISRs. But it won't run. That's correct, since the main code does not call the ISR -- the ISR may, however, call elements of the main code.

3. Salvo does not detect or need to know that there was an interrupt. That would be an example of polling.

Instead, the interrupt simply happens at any unpredictable time. If you happen to call a Salvo service (e.g. OSTimer()) from within an ISR, then that event will make things happen in the RTOS (e.g. task delays will expire if OSTimer() is called at regular intervals).

4. No. Interrupts have the highest priority in any system, whether an RTOS is running or not, whether the RTOS is preemptive or cooperative. If a timer interrupt happens while a task is running, the timer interrupt will be serviced immediately. Savo's tasks (and the tasks of every RTOS) run with interrupts enabled.

------------------

[This message has been edited by aek (edited August 01, 2006).]

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: PIC16F877

Postby 1064453 » Tue Aug 01, 2006 8:47 am


Hi AEK:

In Microchip, when external interrupt
is triggered, the execution will
jump to 0X04 ISR routine address.

How about in Salvo, when an external
interrupt is triggered?
TQ


1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: PIC16F877

Postby aek » Tue Aug 01, 2006 9:23 am

The same.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Next

Return to PICmicro MCUs

Who is online

Users browsing this forum: No registered users and 1 guest

cron