Page 1 of 2

PIC16F877

PostPosted: Sun Jun 25, 2006 8:03 am
by 1064453

Hi AEK:

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


Re: PIC16F877

PostPosted: Tue Jun 27, 2006 7:26 am
by aek
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.

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


Re: PIC16F877

PostPosted: Mon Jul 31, 2006 12:36 am
by 1064453

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.




Re: PIC16F877

PostPosted: Mon Jul 31, 2006 12:45 am
by aek
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.

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


Re: PIC16F877

PostPosted: Mon Jul 31, 2006 10:19 am
by 1064453

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

-




Re: PIC16F877

PostPosted: Tue Aug 01, 2006 1:37 am
by aek
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 ...

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


Re: PIC16F877

PostPosted: Tue Aug 01, 2006 5:02 am
by 1064453

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


-



Re: PIC16F877

PostPosted: Tue Aug 01, 2006 5:39 am
by aek
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).]


Re: PIC16F877

PostPosted: Tue Aug 01, 2006 8:47 am
by 1064453

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



Re: PIC16F877

PostPosted: Tue Aug 01, 2006 9:23 am
by aek
The same.

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