Page 1 of 1

Interrupt

PostPosted: Wed Mar 12, 2008 9:33 am
by Gerald
Hi,

could u explain how interrupts are working with salvo? is an interrupt suspending a task?

i saw i have to define somthing like:
SIGNAL(SIG_OUTPUT_COMPARE1A)
{
OSTimer();
}
what is it doing?

i got a:
driver.c:41: multiple definition of `__vector_11'
main.o:main.c:98: first defined here


Re: Interrupt

PostPosted: Wed Mar 12, 2008 9:43 am
by aek
In most applications, OSTimer() is called periodically to provide delay and timeout services.

Most users do this by calling OSTimer() from an interrupt.

This is not related to task switching per se.

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


Re: Interrupt

PostPosted: Wed Mar 12, 2008 9:45 am
by aek
So, assuming you are already using that interrupt ("vector 11), just setup your code to call OSTimer() from another interrupt.

Typically, OSTimer() is called from an ISR at 100Hz.

It doesn't matter which ISR you call OSTimer() from. You can also call OSTImer() from an ISR that does other things as well.

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


Re: Interrupt

PostPosted: Thu Mar 13, 2008 12:10 am
by Gerald
what happens if an interrupt occurs if a task is running? it will break the task and go to the ISR then back to the task?

another thing:
why is this not working? maybe somth. do to with the priorities? only task PRIO_Blink is running;/ the context switch to the other task is not working?

code:

#define PRIO_COUNT 10 /* task priorities*/
#define PRIO_SHOW 10 /* "" */
#define PRIO_Blink 2 /* "" */

void TaskCount( void )
{
InitPORT();

for (; ;) {
counter++;

if ( !(counter & 0x01FF) )
OSSignalBinSem(BINSEM_UPDATE_PORT_P);

OS_Yield(TaskCount1);
}
}

void TaskShow( void )
{
for (; ;) {
OS_WaitBinSem(BINSEM_UPDATE_PORT_P, OSNO_TIMEOUT, TaskShow1);

PORT = (PORT & ~0xFE) | ((counter >> 8) & 0xFE);

OS_Yield(TaskShow1);
}
}

void TaskStepperMotorDriver()
{
static int toggle = 0;

DDRB |= (1<<PB1);

for (; ;)
{
if(toggle == 0)
{
PORTB |= (1 << PB1);
toggle = 1;
}
else
{
PORTB |= (0 << PB1);
toggle = 0;
}

OS_Yield(TaskBlink1);
}
}


bye

[This message has been edited by Gerald (edited March 13, 2008).]

[This message has been edited by aek (edited March 13, 2008).]


Re: Interrupt

PostPosted: Thu Mar 13, 2008 7:34 am
by aek
quote:
what happens if an interrupt occurs if a task is running? it will break the task and go to the ISR then back to the task?
Yes.
quote:
why is this not working? maybe somth. do to with the priorities? only task PRIO_Blink is running;/ the context switch to the other task is not working?
Correct. Your highest-priority only yields (never delays or waits). Therefore it is always the highest-priority eligible task. Therefore only it runs. Lower the priority and the other tasks will run.

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


Re: Interrupt

PostPosted: Mon Mar 17, 2008 1:41 am
by Gerald
i didnt add:

SIGNAL(SIG_OUTPUT_COMPARE1A)
{
OSTimer();
}