Page 1 of 1

array strange behaviour

Posted: Thu Apr 16, 2009 10:29 pm
by benp
On a 18F2550, the arrays sometimes don't react as they should.
On the attached file (Robot_ir_v4testbug2.fcf), I highlighted the problem.
Robot_ir_v4testbug2.fcf
(35.65 KiB) Downloaded 272 times
I test an array at the begginning of my software not modified (a line follower robot with RC5-IR remote control)

If I write in a calculation box:
--------------------
xcapt[1] = 7
c = 1
MODE = xcapt[c]
----------------------
If I ask for an output on the LCD, I have
xcapt[1] -> 7 on LCD
xcapt[c] -> 8 on LCD
MODE -> 8 on LCD
It should be should be 7/7/7. Simulation give 7/7/7

If I copy the code in a new program, the result is OK (7/7/7)
The same code in a bigger programm can sometime be OK (7/7/7) too. The result is OK on the file: Robot_ir_v8_0bug.fcf
Robot_ir_v8_0bug.fcf
(79.88 KiB) Downloaded 278 times
Somebody have an explanation for that?

Re: array strange behaviour

Posted: Mon Apr 20, 2009 10:49 am
by Steve
Please post the C code file that was generated.

Re: array strange behaviour

Posted: Tue May 05, 2009 9:29 pm
by benp
Here is the generated c code
File with bug:
Robot_ir_v4testbug2.c
(41.69 KiB) Downloaded 315 times
File with no bug:
Robot_ir_v8_0bug.c
(77.3 KiB) Downloaded 302 times

Re: array strange behaviour

Posted: Wed May 06, 2009 7:41 am
by Steve
I can't see anything obviously wrong with the C code that is generated.

It would help if you can create a very simple program that shows this problem and then send us all of the files that are generated (.fcf, .c, .casm, .asm, etc).

Re: array strange behaviour

Posted: Wed May 06, 2009 1:04 pm
by benp
I found where the problem come from.
There is a bug when:
"Extended CPU enable" is set" to "enable"
There is no bug when:
"Extended CPU enable" is set" to "disable"
The problem is solved for me.
I don't know if flowcode should work with enable.

Re: array strange behaviour

Posted: Wed May 06, 2009 1:51 pm
by Steve
Thank you very much for solving this problem!!

I've just looked on the BoostC forums and it says there that the BoostC compiler does not support this XINST configuration setting in the 18F2550 and that it can cause problems with accessing variables in RAM.