Page 1 of 1

OSTimer() and ISR's

PostPosted: Wed Aug 09, 2006 6:36 am
by piratemurray

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

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


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,

¬ my main.c looks like this

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


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;


void TaskTemp( void )
/* setup ADC12 to read ch 10, etc. */
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
debug_printf("the temp is: %d C
", DegC);

void main(void)
debug_printf("world says hello
debug_printf("hello world
OSCreateTask(TaskTemp, Task1_P, 7);
OSCreateTask(Timer_A, Task2_P, 7);
for (;;)

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

#define OSBYTES_OF_TICKS                        2
#define OSEVENTS 2
#define OSTASKS 3

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

¬ thanks in advance!!

Re: OSTimer() and ISR's

PostPosted: Thu Aug 10, 2006 6:54 am
by piratemurray
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

Re: OSTimer() and ISR's

PostPosted: Wed Feb 21, 2007 7:06 am
by Claudiu
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.

Re: OSTimer() and ISR's

PostPosted: Wed Feb 21, 2007 9:10 am
by aek
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).


Re: OSTimer() and ISR's

PostPosted: Mon Feb 26, 2007 5:01 am
by Claudiu
Thank you Andrew