I suspect the problem is here:
#define ARRAY_SIZE 576
float I_1[ARRAY_SIZE]; //My huge array
Since each float uses 4 bytes and each double uses 8 bytes,
this is allocating a single array that uses over 2 000 bytes of RAM.
The PIC18F4520 has 1 536 bytes of RAM -- not enough to store that entire array, much less that array plus all the other variables used in your program.
So you must
- upgrade to a bigger MCU with more on-chip RAM, or
- somehow attach some kind of off-chip RAM, or
- figure out a way to use less RAM (perhaps a smaller ARRAY_SIZE, or perhaps using some 16-bit or 8-bit data type that requires less RAM per item in the array, or perhaps somehow storing some of that data in FLASH, or ...)
or some combination of the above.
Many C programming language teachers spend a lot of time explaining that arrays can be accessed using pointers.
Much like many chemistry teachers spend a lot of time explaining how molecules can be built up from individual atoms.
Much like many physics teachers spend a lot of time explaining how atoms can be built up from individual protons and neutrons.
While doing it that way can be very educational, it's unnecessarily complicated and there's usually a simpler, better way of getting the desired end result.
(There are cases where you need to use pointers, but this doesn't appear to be one of them).
An important skill in debugging is taking a program with a known bug and figuring out the exact step where things seem to go wrong.
It sounds like you think the problem is on line
I_1_ptr[i] = IL_1 - IO_1 * (exp(Q * V_1/ (NS * N * K * temperature)) - 1.0) - V_1/Rsh;
That line does many things. It's difficult for a single-step debugger to figure out exactly which thing is going wrong on such a complicated line.
If I were having this problem, my first action would be to break that line into a bunch of smaller lines and then single-step through those smaller, simpler lines to narrow down where the problem is.
Perhaps something like
denominator = NS * N * K * temperature;
ratio = Q * V_1 / denominator;
temp_1 = exp(ratio) - 1.0;
temp_2 = IL_1 - IO_1 * temp_1 - V_1/Rsh;
I_1[i] = temp2; // normal array access -- pointers not necessary here.
and check that you're getting the expected values at each step.
Which step is giving unexpected results?
An important skill in debugging is reducing a big program with a known bug to a very small program that exhibits the same bug.
Could you trim out the parts of your program before and after the line that does something unexpected -- perhaps by setting variables before that line to some constant value rather than going through long series of calculations -- to give us a very short, but complete program that gives the unexpected behavior?