Pumpkin, Inc.

Pumpkin User Forums

Interrupt

For issues specific to Atmel's AVR and MegaAVR microcontrollers, including Atmel AVRStudio and ImageCraft's ICCAVR C compiler.

Interrupt

Postby Gerald » Wed Mar 12, 2008 9:33 am

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

Gerald
 
Posts: 24
Joined: Tue Mar 11, 2008 11:00 pm

Re: Interrupt

Postby aek » Wed Mar 12, 2008 9:43 am

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.

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

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

Re: Interrupt

Postby aek » Wed Mar 12, 2008 9:45 am

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.

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

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

Re: Interrupt

Postby Gerald » Thu Mar 13, 2008 12:10 am

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).]

Gerald
 
Posts: 24
Joined: Tue Mar 11, 2008 11:00 pm

Re: Interrupt

Postby aek » Thu Mar 13, 2008 7:34 am

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.

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

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

Re: Interrupt

Postby Gerald » Mon Mar 17, 2008 1:41 am

i didnt add:

SIGNAL(SIG_OUTPUT_COMPARE1A)
{
OSTimer();
}

Gerald
 
Posts: 24
Joined: Tue Mar 11, 2008 11:00 pm


Return to Atmel AVR and MegaAVR

Who is online

Users browsing this forum: No registered users and 0 guests

cron