Subject:
|
Re: I've got what Iain Hendry's got, was Re: Swan Firmware
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Sat, 16 Jul 2005 15:45:21 GMT
|
Viewed:
|
6429 times
|
| |
| |
In lugnet.robotics.rcx.nqc, John Hansen wrote:
> In lugnet.robotics.rcx.nqc, Steve Lane wrote:
> > I've got the flashing five problem as well, and it's really annoying, I spent
> > most of my Friday in vain trying to fix it.
>
> Can you please email me the NQC source so that I can generate the listing to see
> if possibly the compiler is generating invalid code?
>
> John Hansen
Hi John
I've fixed the problem. I tracked it down by commenting out parts of my program.
Luckily I started on the function containing the problem So I found it very
quickly. Solving the problem took longer though.
As you can see below I've commented out the line "SetPower(OUT_B,loctemp);"
twice. When I ran the program it no longer crashed, although it didn't work
either without this line. What I did, was replace it with
"motorPower128(1) = loctemp*32;" a function that does exactly the same thing.
I'm guessing that the problem was simply running out of memory or stack space
because this function worked perfectly the first way round in the test program
so it can't be a code generation error, unless it's generating hugely size
inefficent code.
I guess this is why "motorPower128(1) = loctemp*32;" worked. It just generates
more size efficent code.
I only added the local variable "loctemp" to see if it would solve the problem.
task BSpeed()
{
while(1)
{
UseSpeed = (SENSOR_2 - globalend) + 8;
if (UseSpeed < 0){UseSpeed = 0;}
if (UseSpeed > 16){UseSpeed = 16;}
if(UseSpeed > 8)
{
int loctemp=UseSpeed-9;//changed from 9 to 8
motorPower128(1) = loctemp*32;
// SetPower(OUT_B,loctemp);
OnRev(OUT_B);
}
else
{
if(UseSpeed==8)
{
SetPower(OUT_B,OUT_FULL);
SetOutput(OUT_B,OUT_OFF);
}
else
{
if(UseSpeed < 8){
int loctemp=7-UseSpeed;
//SetPower(OUT_B,loctemp);
motorPower128(1) = loctemp*32;
OnFwd(OUT_B);
}
} }
}
}
Steve
|
|
Message is in Reply To:
23 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|