Pumpkin, Inc.

Pumpkin User Forums

SALVO and PIC16C54

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

SALVO and PIC16C54

Postby luben » Sat Jan 27, 2001 8:49 am

Hello,

But 16C57 has 2048 words memory! It's more then enough to run SALVO with event, delays and timeouts. I mean, some of them has enough memory.
Anyway, I try to avoid to use such processors - HiTech C don't support them well. I used to have big troubles with them, so I really understand you.

Regards
Luben

luben
 
Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: SALVO and PIC16C54

Postby luben » Sat Jan 27, 2001 9:51 am

Hello,

is it possible to run SALVO on 12 bit core PIC processors. They have 2 level deep stack, but HiTech compiler makes all calls like GOTO with look up tables, so they don't consume stack levels, except the ISR routines.
Do you have some experience about other 12 bit core PIC - 12C509, 16C57, etc.
Regards
Luben

luben
 
Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: SALVO and PIC16C54

Postby aek » Sat Jan 27, 2001 10:16 am

We have not attempted to run Salvo on any of the 12-bit core processors. Our concern is mainly that the Salvo code will consume too much of the limited ROM of those PICmicros.
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: SALVO and PIC16C54

Postby luben » Sun Jan 28, 2001 8:34 am

Hello,

To make one project to be compiled on HiTech it's not the same to make it working. I'm afraid that this example could have hidden problems - until it's not checked on real processor or at least on simulator I can't garantee nothing. I think it's not big deal to test it on the MPLAB similator - it brings good results.

HiTech makes all call/returns with GOTO instructions - look up tables. They consume more ROM, but no stack at all. Of course you can skip this option by declaring one function "fastcall" - this keyword prevents HiTech from creating look up tables for this function and will use the standart call/return way.

I asked this question because I knew that HiTech can use lookup tables and you can make on 12 bit core processors complicated projest, without worrying about stack depth. Well, you have to avoid to make deep calls - HiTech don't report any errors, but the final project doesn't work.

Regards
Luben

luben
 
Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: SALVO and PIC16C54

Postby aek » Sun Jan 28, 2001 8:39 am

What sort of differences have you encountered between the MPLAB simulator and the real chips?

My tests so far with PIC C on the 16C57 show that they are doing all of the call-to-goto conversions correctly. Right now I am investigating just how much of Salvo can be used (delays, events, delays+events) on the 12-bit devices. It looks very promising ...

The only time I have found a difference between MPSIM and PIC C was when beta testing picc-18 v7.99 -- our code would work in MPSIM but not on a real part. Eventually we discovered (around the same time as HI-TECH) that the indir_func in the picc-18 library didn't work because of the limitations of the movff instruction. We coded a workaround (the same as is now used in picc-18 v8.00 and higher) and everything works correctly.

Obviously there were (and may still be) some bugs in the PIC C and picc-18 compilers, but in terms of Salvo, PIC C v7.86PL3 and higher, and picc-18 v8.01 and higher appear to be trouble-free.

If I understand the method used by HI-TECH to replace the call...return stack with gotos, you can still do deep calls quite successfully on the 12-bit PICmicro MCUs. You just can't have a call graph that involves the need for more than two call instructions, i.e. two separate functions called at different depths in multiple, independent call craphs.

[This message has been edited by aek (edited January 28, 2001).]

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

Re: SALVO and PIC16C54

Postby luben » Sun Jan 28, 2001 9:00 am

Hello,
My bad experience is with implementation of one tables into PIC16C57 - I made a thermal printer and wanted to put the character generator into ROM. It never began to work on 16C57, despite that the simulator showed that it have to work.

Well, after I migrate to 16F874 everything was OK.

What I saw like mistake in HiTech is that the long tables are recorded like "retlw" instructions. But there is limitation - you can use only the first half of the page for such tables and any call to function will point to the first half of the program page (see Microchip manual for call instruction limitation). I mean - if one fuction resides in the second half of the page you can't call it directly (I use to put a goto instruction in the first half of the page, pointing the function, that resides into second half).

HiTech crossed this boundary (without reporting errors) and the project crashed. In the simulator I didn't receive any problems. After I saw the assembler code I understood that there is hard to make such project working on 16C57 - it was not impossible but, I had to care for all resources and to check every time after compiling the source code.


From other side I have sevaral complicated projects on 12C508 and they all work excellent. I think there is no limitation for SALVO to work on 12 bit core processors.

Luben

[This message has been edited by luben (edited January 28, 2001).]

[This message has been edited by luben (edited January 28, 2001).]

[This message has been edited by luben (edited January 29, 2001).]

luben
 
Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: SALVO and PIC16C54

Postby aek » Sun Jan 28, 2001 10:17 am

Just for kicks, I got a Salvo application running on a PIC16C57. I had to make a custom portuser.h, and also two additions to the Salvo source code.

Results, for the following program:

code:
#include "salvo.h"


#define TASKA_P OSTCBP(0)
#define TASKB_P OSTCBP(1)


void TaskA ( void );
void TaskB ( void );


_OSLabel(TaskA1)
_OSLabel(TaskB1)
_OSLabel(OSSchedRtn)


int counter;


void main ( void )
{
OSInit();

OSCreateTask(TaskA, TASKA_P, 3);
OSCreateTask(TaskB, TASKB_P, 3);

for (; ;) {
#if !OSUSE_INLINE_OSSCHED
OSSched();
#else
#include "sched.c"
#endif
}
}


void TaskA ( void )
{
for (;;) {
counter++;

OS_Yield(TaskA1);
}
}


void TaskB ( void )
{
TRISC = 0x00;


for (;;) {
PORTC ^= 0x55;


OS_Yield(TaskB1);
}
}


Memory Usage Map:

Program ROM $0000 - $0012 $0013 ( 19) words
Program ROM $009D - $0231 $0195 ( 405) words
Program ROM $07FF - $07FF $0001 ( 1) words
$01A9 ( 425) words total Program ROM

Bank 0 RAM $0008 - $0016 $000F ( 15) bytes total Bank 0 RAM
Bank 3 RAM $0070 - $0077 $0008 ( 8) bytes total Bank 3 RAM


It's very interesting to see how PIC C handles all those "call ... returns".

Anyway, this shows that Salvo can be used on the 12-bit PICs. We'll try to integrate support into the v2.2 release.

[This message has been edited by aek (edited January 28, 2001).]

-------
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 1 guest

cron