Pumpkin, Inc.

Pumpkin User Forums

OSRpt Function with PIC18F6720

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

OSRpt Function with PIC18F6720

Postby Fred » Wed Feb 16, 2005 1:13 am

Hello, I have to implement a commercial RTOS in our new project, so I try to merge Salvo with the part of the project I already coded before buying it.

I tried to bundle Salvo in my code, but when I run it( I have ICE4000 Debugger) the task are never called.. So I'm trying to use the OSRpt function to see whats wrong in my code but I can't get anything that makes sense. I replaced my real task with 2 dummy task :
------------------------------

code:
void TaskA( void )
{
for (;;)
OS_Yield(TaskA1);
}

void TaskB( void )
{
for (;;)
OS_Yield(TaskB1);
}

OSInit();

OSCreateTask(TaskA, OSTCBP(1), 10);
OSCreateTask(TaskB, OSTCBP(2), 10);
for (;;)
{
OSSched();
OSRpt();
}



-----------------------------------
But I still received confuse data from OSRpt:

code:
Salvo 2..  Ticks: 0
EligQ:
DelayQ:
task stat prio addr t-> e->delay
1 wtto 9 000016EFh 181
3 dlyd 4 0000FFE6h . 239

evnt type t-> value
1 ERR
2 dstr
3 dstr
4 ERR
5 ERR



I also tried to use the OSRpt function in a simpler code. I modified one of the example code and add USART function. Everything run perfectly but the ORSpt function didn't send any data to the port.

any suggestions?

Regards

Fred

[This message has been edited by aek (edited February 16, 2005).]

Fred
 
Posts: 7
Joined: Wed Feb 16, 2005 12:00 am
Location: Quebec, Canada

Re: OSRpt Function with PIC18F6720

Postby aek » Wed Feb 16, 2005 1:20 am

Hi Fred.

The code you have written looks fine.

The OSRpt() output is not from that program ... it shows that nothing is eligible (should have two tasks eligible), and that the task with OSTCBP(1) is waiting with a timeout, and the task with OSTCBP(3) is delayed. But you don't have tasks like that ... both of your tasks are always eligible.

So I suspect that your program has more code (perhaps another module somewhere?) than what you posted.

Also, why does OSRpt() show v2 when the current version is v3.2? Please be sure to be using Salco Lite for PICmicro(R) MCUs v3.2.3.

For OSRpt() to send data, you must define the putc() function -- see the Salvo User Manual for more information.

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

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

Re: OSRpt Function with PIC18F6720

Postby Fred » Thu Feb 17, 2005 6:57 am

Hi aek,
I don't know why I get "2.." as the version number, I installed the last version 3 weeks ago. Anyway the output of the OSRpt seems to be corrupted.

Here is a completly new code I wrote to test a very basic salvo application...
--------------------------------

code:
#include <main.h>
#include <salvo.h>
#include <p18f6720.h>
#include <usart.h>
#include <p18cxxx.h>
#include <definition.h>
#include <stdio.h>

#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config DEBUG = ON
#define bitTMR2IE PIE1bits.TMR2IE
#define DisableTMR2() do { bitTMR2IE = 0; } while (0)
#define EnableTMR2() do { bitTMR2IE = 1; } while (0)

/* use #defines for legibility. */
#define TASK1_P OSTCBP(1)
#define TASK2_P OSTCBP(2)
#define TASK3_P OSTCBP(3)

#define BINSEM1_P OSECBP(1)

void putch(char c);

/* use _OSLabel() to create context-switching labels. */
_OSLabel(Task1a)
_OSLabel(Task2a)
_OSLabel(Task3a)


/* Task1 toggles bit1 on PORT every 100ms (assumes */
/* clock). */


/* Task2 waits for binary semaphore #1 to be signaled, */
/* then toggles bit2 on PORT. */
void Task2( void )
{
for (;;) {
OS_WaitBinSem(BINSEM1_P, OSNO_TIMEOUT, Task2a);
PORT ^= 0x04;
}
}


/* Task3 delays itself for 400ms, then signals binary */
/* semaphore #1 and toggles bit3 on PORT. */
void Task3( void )
{
for (;;) {
OS_Delay(40, Task3a);
PORT ^= 0x08;
OSSignalBinSem(BINSEM1_P);

}
}

void Task1(void)
{
for (;;)
{
OS_Delay(100,Task1a);
printf("TEST");
putch(0x0A);

}
}

void putch(char c)
{
putc1USART(c);
}

void main( void )
{
// InitPORT();

Init();
TRISC = 0;
Open1USART (USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_LOW, 64); // X= (Fosc/Baud/z)-1 si BRGH=Low z=64 sinon z=16
// X= (20000000/4800/64)-1 = 64.104 => 64



/* initialize Salvo. */
OSInit();

/* create the three tasks */
OSCreateTask(Task1, TASK1_P, 3);
OSCreateTask(Task2, TASK2_P, 7);
OSCreateTask(Task3, TASK3_P, 14);


/* initialize binary semaphore to 0. */
OSCreateBinSem(BINSEM1_P, 0);

/* enable interrupts. */
OSEi();

/* start multitasking. */
for (;;)
{
OSSched();
DisableTMR2();
OSRpt();
EnableTMR2();
}
}


#if defined(SYSE)

#pragma interrupt IntVector save=PROD,section(".tmpdata")

void IntVector( void )
{

static char i = 195; /* prescalar, 195 x 51us = 10ms */

if ( INTCONbits.T0IE && INTCONbits.T0IF ) {
INTCONbits.T0IF = 0;

if ( !(--i) ) {
i = 195;
PORT ^= 0x01;
OSTimer();
}
}
}

#pragma code IntVectorHigh = 0x08
void IntVectorHigh( void )
{
_asm
goto IntVector
_endasm
}


#endif



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

I'm using MPLAB C18 compiler.

The printf function work but OSRpt still dont want to output anything..

Can you see something wrong it that code?

[This message has been edited by aek (edited February 17, 2005).]

Fred
 
Posts: 7
Joined: Wed Feb 16, 2005 12:00 am
Location: Quebec, Canada

Re: OSRpt Function with PIC18F6720

Postby aek » Thu Feb 17, 2005 8:17 am

Hi Fred.

Thank you for your detailed response.

quote:
I verified a lot of time I have the last version...
As long as it's v3.2.3
quote:
SYSE, MAKE_WITH_STD_LIB are added in MPLAB as symbol in the Project parameters..
For Salvo Lite it should be MAKE_WITH_FREE_LIB.
quote:
If I disabled them, the prog can get out of OSRpt!
That's odd, see below.
quote:
sfc18sfa.lib I updated the lkr file for the 1f6720 already...
Make sure that your project is being built with MPLAB-C18's small memory settings ...
quote:
I need to know.. what kind of "putch()" OSRpt need? Is it called by the printf() function?
It uses printf() only, so as long as you have a working printf(), it should work.
quote:
ou said you work with interrupt driven UART function, how your code can send data on the port if we need to disable interrupt before calling OSRpt?
My comment was for your code example, which does not use interrupt-driven UARTs ...

I'm not really sure why you're having the problem, so the best thing is to email us the project and we'll figure it out.

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

[This message has been edited by aek (edited February 17, 2005).]

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

Re: OSRpt Function with PIC18F6720

Postby aek » Thu Feb 17, 2005 9:24 am

Hi Fred.

1) People still seem to install the earlier versions of Salvo -- please verify that you are running v3.2.3. You can see this under Start -> Programs -> Pumpkins -> Salvo ...

2) You appear to have used Salvo's ex1 as the basis for your example. Did you also define SYSE? Did you define PORT? And we need to see your salvocfg.h, too. When writing your own application, you should remove all of those conditional symbols (SYSE, MAKE_WITH_STD_LIB, etc. from your code).

3) Why does your code have TMR2 code in it? TMR2 isn't used anywhere.

4) Try disabling all interrupts around the call to OSRpt().

5) Don't include two PIC18 header files -- just include p18f6720.h.

6) Which Salvo library are you linking to? The Salvo projects are designed for the 18c452, and you're using the 'F6720. See the Salvo Compiler Reference Manual for MPLAB-C18.

7) I haven't used putc1USART() -- I always write interrupt-based UART handlers. But if printf("TEST") works in Task1(), then OSRpt() should also work.

If you can't get it to work, .zip up the whole project and send it to Salvo support, and we'll get it working for you.

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

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

Re: OSRpt Function with PIC18F6720

Postby Fred » Thu Feb 17, 2005 11:31 am

----------
1) People still seem to install the earlier versions of Salvo -- please verify that you are running v3.2.3. You can see this under Start -> Programs -> Pumpkins -> Salvo ...
----------------
I verified a lot of time I have the last version...
---------------
2) You appear to have used Salvo's ex1 as the basis for your example. Did you also define SYSE? Did you define PORT? And we need to see your salvocfg.h, too. When writing your own application, you should remove all of those conditional symbols (SYSE, MAKE_WITH_STD_LIB, etc. from your code).
------------
SYSE, MAKE_WITH_STD_LIB are added in MPLAB as symbol in the Project parameters..
------------

3) Why does your code have TMR2 code in it? TMR2 isn't used anywhere.
-------------------------
That was for an old test... I removed it..
--------------------------

4) Try disabling all interrupts around the call to OSRpt().
--------------------
If I disabled them, the prog can get out of OSRpt!
--------------------

5) Don't include two PIC18 header files -- just include p18f6720.h.
-----------------------
Done!

-----------------------
6) Which Salvo library are you linking to? The Salvo projects are designed for the 18c452, and you're using the 'F6720. See the Salvo Compiler Reference Manual for MPLAB-C18.
----------------------
sfc18sfa.lib I updated the lkr file for the 1f6720 already...
----------------------

7) I haven't used putc1USART() -- I always write interrupt-based UART handlers. But if printf("TEST") works in Task1(), then OSRpt() should also work.
----------------------
I get "TEST" on my terminal screen once by second..

I need to know.. what kind of "putch()" OSRpt need? Is it called by the printf() function?
I used the printf function from "stdlib.h" included with C18 compiler..

You said you work with interrupt driven UART function, how your code can send data on the port if we need to disable interrupt before calling OSRpt?


thanks for your fast reply!

Fred

Fred
 
Posts: 7
Joined: Wed Feb 16, 2005 12:00 am
Location: Quebec, Canada

Re: OSRpt Function with PIC18F6720

Postby Fred » Fri Feb 18, 2005 10:32 am

Hi aek,

I have found the solution, I use now the sfc18lfa library and I set the memory model in MPLab C18 parameter to "Large".

Now I get some good data from OSRpt except the version number that is still weird. I get 2.D./ and sometime the two last digit change..

Now I'm trying to use OSSignalMsg and OS_WaitMsg. I want to pass a char integer in the same time but without success..

Do we absolutely have to use OStypeMsgP as variable or we can use other variable type with these functions? By the way, I can't use "*(char *)msgP" code to do the conversion in C18 compiler..

Regards

Fred

Fred
 
Posts: 7
Joined: Wed Feb 16, 2005 12:00 am
Location: Quebec, Canada

Re: OSRpt Function with PIC18F6720

Postby aek » Fri Feb 18, 2005 10:45 am

Hi Fred.
quote:
Do we absolutely have to use OStypeMsgP as variable or we can use other variable type with these functions?
Yes, because it resolves to a void pointer specific to the compiler. Failure to use OStypeMsgP when casting what you're signaling can lead to all sorts of problems. It's very important to use Salvo's predefined stypes like OStypeMsgP. Without them, you can run into all sorts of problems. They are provided (and tested) precisely to save you the headaches.
quote:
By the way, I can't use "*(char *)msgP" code to do the conversion in C18 compiler..
. This cast is used in Salvo's tutorial tu6. No problems here, but there is a minor problem in salvo ut u1isr.c -- change TMR0 on line 52 to TMR0L and rebuild ...

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

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


Return to Coding

Who is online

Users browsing this forum: No registered users and 5 guests

cron