------------------
------------------
Please see my code:
salvocfg.h
code:
#if defined(MAKE_WITH_FREE_LIB)
/* */
/* Salvo Lite build */
/* */
#define OSUSE_LIBRARY TRUE
#define OSLIBRARY_TYPE OSF
#define OSLIBRARY_CONFIG OSA
#define OSEVENTS 2
#define OSEVENT_FLAGS 0
#define OSMESSAGE_QUEUES 0
#define OSTASKS 3
main.c
code:
#include "main.h"
#include "salvo.h"
/* use #defines for legibility. */
#define TASK1_P OSTCBP(1)
#define TASK2_P OSTCBP(2)
#define TASK3_P OSTCBP(3)
#define BINSEM1_P OSECBP(1)
#define BINSEM2_P OSECBP(2)
/* use _OSLabel() to create context-switching labels. */
_OSLabel(Task1a)
_OSLabel(Task2a)
_OSLabel(Task3a)
void Task1( void )
{
for (; ;) {
OS_WaitBinSem(BINSEM1_P, OSNO_TIMEOUT, Task1a);
PORT ^= 0x02;
UDR='1';
OS_Yield();}
}
void Task2( void )
{
for (; ;)
{OS_WaitBinSem(BINSEM2_P, OSNO_TIMEOUT, Task2a);
PORT ^= 0x04;
UDR='2';
OS_Yield();
}
}
void Task3( void )
{
for (; ;) {
PORT ^= 0x08;
UDR='3';if(PINA&(1<<0))
OSSignalBinSem(BINSEM1_P);
if(PINA&(1<<1))
OSSignalBinSem(BINSEM2_P);
OS_Delay(10, Task3a);
}
}int main( void )
{
InitPORT();
DDRA=0x00;
PORTA=0xFF;// Init();
TCCR1B = 0x00; // Stop Timer1
TCNT1H = 0x00; // Clear Timer1
OCR1AH = 0x00; // Set Compare A to 39
OCR1AL = 0x26; // ((4MHz/1024)/39) = 10ms (9.984ms) timer
TIMSK = 0x10; // Compare A Interrupt enable
TCCR1B = 0x0D; // Start Timer1 with clk/1024
UBRR=25;
UCSRA=0x00;
UCSRB=0x08;
/* initialize Salvo. */
OSInit();
/* create the three tasks */
OSCreateTask(Task1, TASK1_P, 2);
OSCreateTask(Task2, TASK2_P, 2);
OSCreateTask(Task3, TASK3_P, 2);
/* initialize binary semaphore to 0. */
OSCreateBinSem(BINSEM1_P, 0);
OSCreateBinSem(BINSEM2_P, 0);
/* enable interrupts. */
OSEi();
/* start multitasking. */
for (; ;)
{
OSSched();
}
}
[This message has been edited by MaxMax1 (edited January 02, 2008).]
[This message has been edited by aek (edited January 03, 2008).]
1) Remove the OS_Yield() calls. They're unnecessary and will confuse you re the runtime behavior of the system.
2) We have found that the AVR simulator does not always work properly ... see e.g. http://www.pumpkininc.com/ubb/Forum22/HTML/000018.html.
------------------
A common error is that the salvocfg.h you think you are using is not in fact the one used by the project (due to incorrectly defined include paths). A quick way to test that is to add an #error Hello! directive to your salvocfg.h and rebuild -- it should result in a Hello! error when building.
------------------
------------------
I also tested it on my AVR board, with Porttoggling and UART output. So its not only a problem with AVRStudio debugger/Simulator.
I ask because last week or so I had some problems with the latest WinAVR and the latest AVR Studio on the mega2560, and eventually after a couple of restarts, etc. everything suddenly worked OK (but before that I had problems launching the simulator).
------------------
Just like OStcbArea[0], [1] & [2] for your application.
So if it doesn't have those, I would suggest focusing on why those members don't exist.
------------------
Users browsing this forum: No registered users and 1 guest