Pumpkin, Inc.

Pumpkin User Forums

Incorrect RAM page settings on return after OS_Yield

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

Re: Incorrect RAM page settings on return after OS_Yield

Postby aek » Wed Dec 05, 2001 11:17 am

I played around with this one some more, and came up with a minimal test case that exhibits this behavior (RP1 not set on the second iteration of reading EEDATA):

code:
#include <pic.h>


void SimpleFn( void )
{
asm(" clrwdt");
asm(" global _jumpback");
asm(" ljmp _jumpback");
}


main()
{
RD = 1;
while (EEDATA != 0x0D) {
TXREG = EEDATA;

asm(" global _SimpleFn");
asm(" ljmp _SimpleFn");
asm("_jumpback:");


}
}


This happens in the assembler optimizer -- unoptimized code is correct. It's also correct if you make changes, like remove the RD = 1; line.

So it seems to me that you got very unlucky and this bug befell you. It seems to be triggered by the presence of an ljmp instruction prior to the loop test. By placing your call to nulltask(), or indeed by placing just about any C-language statement, this problem is avoided. You could put the second RD = 1; statement down there, for instance. But some statements don't fix it, e.g. PORTB = 0;. Weird.

I've forwarded more info to them. For now, it seems that an extra statement (the null statement is not enough) as the last statement in a while() loop will fix this problem. But it's totally unpredictable as to when it will occur. It may also occur in for loops, do-while's, etc. -- I don't know.


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

[This message has been edited by aek (edited December 05, 2001).]

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

Re: Incorrect RAM page settings on return after OS_Yield

Postby cstocks » Thu Dec 06, 2001 1:04 am

Andrew,

I will wait for Hi-Tech to post a patch, and keep a look out for anomalous behaviour.

Regards,

Colin

PS The application works fine - and I'm rapidly learning a considerable amount of new "stuff" about using an RTOS.

cstocks
 
Posts: 7
Joined: Tue Oct 23, 2001 11:00 pm
Location: Crowborough, East Sussex, UK

Re: Incorrect RAM page settings on return after OS_Yield

Postby aek » Wed Jan 09, 2002 4:25 am

Matt at HI-TECH has provided me with an updated version of the assembler, aspic.exe, which corrects this bug. I tested it and it handles this problem correctly.

It will be included in the next release of HI-TECH PICC.

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

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

Previous

Return to Coding

Who is online

Users browsing this forum: No registered users and 2 guests

cron