Pumpkin, Inc.

Pumpkin User Forums

PIC32 XC32 Compiler tut5 question...

For issues specific to Microchip's PICmicro® MCUs, including compilers (e.g. HI-TECH PICC & PICC-18, Microchip MPLAB®-C18) and IDEs (e.g. Microchip MPLAB®).

PIC32 XC32 Compiler tut5 question...

Postby jal » Fri Aug 10, 2012 10:01 am

I have been trying Salvo-Lite for a PIC32 project. Microchip is migrating from the C32 to an enhanced compiler XC32 which I did not see listed in the supported compiler list. I was however able to get tut5 to compile/run on an explorer16 board with some manual intervention. Specifically it seems that XC32 does not predefine the macros that the Salvo include files need to correctly configure themselves. Thus to get the tut5 demo to work I have to insert the following...

Code: Select all
// Manually define these to try and force XC32 to compile the code ...
// For some reason the compiler type defs don't get mapped properly.
#define OSTOOLSET_SUPPORTED            TRUE
#define OSCOMPILER                     OSMPLAB_C32
#define OSTARGET                       OSPIC32
#include <salvo.h>


After getting the demo working, I then wanted to experiment with using the OS_Replace() function to utilize one TCB for several different functions depending on the operating mode of the program. In this instance, the compiler failed at the link stage and flags each call to OS_Replace() with "undefined reference to OSReturn()". Apparently this results from the macro expansion of OS_Replace() defined in salvompt.h. I am linking to C:/Pumpkin/Salvo-PIC32/Lib/MCC32/libsalvofmcc32l-t.a.
Is this the wrong library to link? If its correct why is OSReturn() apparently missing?

Thanks
Jim
jal
 
Posts: 9
Joined: Thu Feb 14, 2008 12:00 am

Re: PIC32 XC32 Compiler tut5 question...

Postby aek » Fri Aug 10, 2012 10:32 am

That's a bummer that Microchip is not paying greater attention to migration ... there's little excuse to drop well-used predefined identifiers. Anyway, you correctly saw how to overcome that manually.

All of the Salvo libraries have the same suite of API calls -- it is, however, possible that OS_Replace() is correctly defined in a particular distribution -- the interaction between OS_Replace() and OSReturn() has had a storied life and may not have been implemented properly in the PIC32 Salvo distribution. IIRC, OSReturn()'s code is present in the context switcher, but a label for it may not have been included (hence it is not callable) as it is only called by OS_Replace(), yet its code is part of every context switch (think of an in-line code snippet, that is one exit point of a function, which has a unique entry point applicable to only one function -- all very assembly-language-level stuff).

Anyway, we'll take a look at it, but it may be a while before this issue is resolved. I think you can replace (HaHa) OS_Replace() with OSCreateTask() followed by OS_Yield(), when called from within the task to be replaced.
-------
aek
aek
 
Posts: 1886
Joined: Sat Aug 26, 2000 11:00 pm

Re: PIC32 XC32 Compiler tut5 question...

Postby jal » Fri Aug 10, 2012 10:47 am

Andrew...thanks for the quick response! I will try your suggested workaround and let you know how it behaves.

thnx
Jim
jal
 
Posts: 9
Joined: Thu Feb 14, 2008 12:00 am

Re: PIC32 XC32 Compiler tut5 question...

Postby aek » Fri Aug 10, 2012 12:53 pm

Hmmm .. may be it needs to be

OS_Destroy();
OScreateTask();
OS_Yield();

since you can self-destroy from within a task.

Also, I checked the Salvo MCC32 context switcher, and it is in fact missing OSReturn() ...
-------
aek
aek
 
Posts: 1886
Joined: Sat Aug 26, 2000 11:00 pm

Re: PIC32 XC32 Compiler tut5 question...

Postby jal » Fri Aug 10, 2012 1:58 pm

So far none of the work arounds have been successful ...but thanks for the suggestions.
Regarding your last sequence...
Code: Select all
OS_Destroy();
OSCreateTask(....);
OS_Yield();


I think maybe you want OSDestroy() instead since OS_Destroy() expands to ..
Code: Select all
OSDestroy(); OS_Yield();


....which would reschedule the task after its been destroyed and before it gets to call OSCreateTask()?


So....is this problem the type of thing that I could fix myself if I purchased the Pro or LE versions?

Regards,
Jim
jal
 
Posts: 9
Joined: Thu Feb 14, 2008 12:00 am

Re: PIC32 XC32 Compiler tut5 question...

Postby aek » Fri Aug 10, 2012 3:22 pm

Hi Jim.

You're correct, OS_Destroy() will get you out of the task before you can re-create a new one to use the current one's tcb.

On further reflection, I don't think there's an easy way to implement OS_Destroy() with a correct OSReturn(). I.e., the OS_Replace() macro is not just a minimal-lines implementation, it's likely the only possible implementation, as it is currently written.

Salvo LE would not enable you to fix this, as it contains no source code -- just the same libraries as Salvo Lite, but without any restrictions of the number of tasks & events.

With Salvo Pro, you could add a small snippet of code to the Salvo for MCC32 context switcher (it's in assembly), call it OSReturn(), ensure that it works :-), and then you'd have a working OS_Replace().

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

Re: PIC32 XC32 Compiler tut5 question...

Postby jal » Fri Aug 10, 2012 7:02 pm

OK...thanks for the continued follow through on this issue. I guess this should get added to the "known bugs" for the C32/XC32 Salvo support. I'm not sure if my expertise in PIC32 assembly (or Salvo internals!) would make it very likely to be successful with the assembly module repairs.... but it seems like a shame to forgo all the stuff that Salvo gives. I will consider what options I have and get back to you.

Regards,
Jim
jal
 
Posts: 9
Joined: Thu Feb 14, 2008 12:00 am

Re: PIC32 XC32 Compiler tut5 question...

Postby jal » Wed Dec 19, 2012 8:34 am

In case anyone is following this thread I wanted to report on resolution of the issue. Using the SalvoPro source distribution for the MCC32 I was able to add the necessary assy code bits to get a working OS_Replace(). For Salvo users who are working with the XC32 tool suite it is still necessary to add the additional macro definitions shown in the Initial post of this thread.

Jim
jal
 
Posts: 9
Joined: Thu Feb 14, 2008 12:00 am


Return to PICmicro MCUs

Who is online

Users browsing this forum: No registered users and 1 guest

cron