Pumpkin, Inc.

Pumpkin User Forums

OSTimer() and ISR's

If you can't make Salvo do what you want it to do, post it here.

OSTimer() and ISR's

Postby piratemurray » Wed Aug 09, 2006 6:36 am

hello

i'm trying to get my head round this OSDelay, OSTimer() and ISR thing.

correct me if i'm wrong:

¬ as far as i understand OSDelay needs OSTimer to work otherwise it has no sense of how long the delay should last.

¬ OSTimer can be called in a number of ways but the suggested way seems to be from an overflow from a clock. that is to say when a clock has reached a certain point in its cycle an overflow occurs and an interrupt is emitted.

¬ the period of this overflow is the period that OSTimer() is called and thus defines the delay increment.

what i dont seem to understand is how to implement this ISR for simply delaying a task.

currently i have

code:
void Timer_A (void) __interrupt[TIMERA0_VECTOR]
{
CCR0 += 10000;

OSTimer();
}

in my main.c file before the void main(void) bit. however i have noticed that in the forum many people put this ISR underneath the main bit.

¬ also whilst i can locate the ISR in the main.c file. i cant work out where it has been called. i tried to call it in OSSched by creating a task called TimerA which didn't work.

//--------------------------------------\
i am running salvo pro, crossstudio 1.3,
MSP430F169.
\--------------------------------------//

¬ my main.c looks like this

code:
#include <msp430x16x.h>
#include <salvo.h>
#include <cross_studio_io.h>


_OSLabel(TaskTemp1)
_OSLabel(TimerA1)

unsigned int ADCresult;
unsigned long int DegC;

#define Task1_P OSTCBP(1)
#define Task2_P OSTCBP(2)

void Timer_A (void) __interrupt[TIMERA0_VECTOR]
{
CCR0 += 10000;

/* toggle bit0 on P1OUT to show some life. */
//PORT ^= 0x01;

OSTimer();
}

void TaskTemp( void )
{
/* setup ADC12 to read ch 10, etc. */
ADC12CTL0 = ADC12ON+REFON+REF2_5V+SHT0_6;
ADC12CTL1 = SHP;
ADC12MCTL0 = INCH_10+SREF_1;
OS_Delay(1, label2); //wait 10ms for reference startup
debug_printf("i am waiting 10ms");
ADC12CTL0 |= ENC; //enable conversions
for (;;)
{
ADC12CTL0 |= ADC12SC; // start conversion
OS_Delay(200, label); // wait 2s
debug_printf("i am waiting 2 seconds");
ADCresult = ADC12MEM0; // read result
DegC = ((((long)ADCresult-1615)*704)/4095); // calc. DegC
OS_Yield(TaskTemp1);
debug_printf("the temp is: %d C
", DegC);
}
}

void main(void)
{
debug_printf("world says hello
");
debug_printf("hello world
");
OSInit();
OSCreateTask(TaskTemp, Task1_P, 7);
OSCreateTask(Timer_A, Task2_P, 7);
OSEi();
for (;;)
OSSched();
}


in the debug window the first two lines "hello world" statements appear and then the program stops. actually i cant tell whether it stops or its stuck in an infinite loop or whatever. but it doesnt do anything.

if i comment out the delay lines the program works fine. but without delay. not too sure whats wrong.

¬ my salvocfg.h looks like

code:
#define OSBYTES_OF_TICKS                        2
#define OSBYTES_OF_DELAYS 1
#define OSENABLE_MESSAGES TRUE
#define OSEVENTS 2
#define OSTASKS 3
#define OSENABLE_DELAYS TRUE

¬ ISR's are new to me so i've probably overlooked something quite basic.

¬ thanks in advance!!

piratemurray
 
Posts: 16
Joined: Mon Jul 03, 2006 11:00 pm
Location: london

Re: OSTimer() and ISR's

Postby piratemurray » Thu Aug 10, 2006 6:54 am

okie dokie....... i've figured out what was going on.

¬ i needed to include USE_INTERRUPTS in the preprocessor options where we would define SYSX and MAKE_WITH_SOURCE.

¬ the file isr.c can then be called correctly and inside it has an interrupt vector prototype thingy so no need for futher definitions and what not.

¬ also i'm sure that my salvocfg.h file was completely wrong so i copied the one over from tut5

¬ i also used the main.h from tut5

hopefully anyone else getting stuck on this type of problem will have a better time of figuring it out than i did

piratemurray
 
Posts: 16
Joined: Mon Jul 03, 2006 11:00 pm
Location: london

Re: OSTimer() and ISR's

Postby Claudiu » Wed Feb 21, 2007 7:06 am

Hi, can you tell me what did you do exactly to make interrupts working in cw with MSP430 Core Simulator. Because I test tut5 and it doesn't work.
Claudiu
 
Posts: 6
Joined: Fri Jun 23, 2006 11:00 pm
Location: Bucharest, Romania

Re: OSTimer() and ISR's

Postby aek » Wed Feb 21, 2007 9:10 am

The core simulator in CorssWorks is just a core -- interrupts are not simulated.

I'm not aware of any good MSP430 simulator -- it's much cheaper to simulate on real hardware (e.g. on the MSP430 USB stick).

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

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

Re: OSTimer() and ISR's

Postby Claudiu » Mon Feb 26, 2007 5:01 am

Thank you Andrew
Claudiu
 
Posts: 6
Joined: Fri Jun 23, 2006 11:00 pm
Location: Bucharest, Romania


Return to Coding

Who is online

Users browsing this forum: No registered users and 2 guests