|
|
View previous topic :: View next topic |
Author |
Message |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
int1 arrays USED to work [SOLVED] - programmer error |
Posted: Thu Jul 26, 2012 4:31 pm |
|
|
this code worked properly back with 4.085 and a few versions after but......
Code: |
int1
skipmeK[96]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
// This function WORKS in 4.085 - my old baseline compiler for 18f4525
// but FAILS in 4.135 as follows:
// the bits in skipmek STAY ='1 no matter what
// call with t<12 for EZ check
// called with 'prx'=1 SHOULD set 't' bit to 0
// the 0-12 test printer is to make it EZ to understand what is going bad
void setskipK (int1 prx , unsigned int8 t){
unsigned int8 q;
if (prx) skipmek[t]=0; // inverts prx
else skipmek[t]=1;
printf("InDeX %u :",t);
for (q=0; q<12; q++){
if (skipmek[q]) printf("1,");
else printf("0,");
}
printf("\r\n");
}
|
This has been reported, but not verified or acknowledged by CCS.
Last edited by asmboy on Fri Jul 27, 2012 10:20 am; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jul 26, 2012 5:03 pm |
|
|
I made a test program and compiled it with vs. 4.135 and ran it in MPLAB
vs. 8.86 simulator and got this:
Quote: |
InDeX 0 :0,1,1,1,1,1,1,1,1,1,1,1,
InDeX 1 :0,0,1,1,1,1,1,1,1,1,1,1,
InDeX 2 :0,0,0,1,1,1,1,1,1,1,1,1,
InDeX 3 :0,0,0,0,1,1,1,1,1,1,1,1,
InDeX 4 :0,0,0,0,0,1,1,1,1,1,1,1,
InDeX 5 :0,0,0,0,0,0,1,1,1,1,1,1,
InDeX 6 :0,0,0,0,0,0,0,1,1,1,1,1,
InDeX 7 :0,0,0,0,0,0,0,0,1,1,1,1,
InDeX 8 :0,0,0,0,0,0,0,0,0,1,1,1,
InDeX 9 :0,0,0,0,0,0,0,0,0,0,1,1,
InDeX 10 :0,0,0,0,0,0,0,0,0,0,0,1,
InDeX 11 :0,0,0,0,0,0,0,0,0,0,0,0,
|
Is that correct ? The zeros are cumulative because I don't re-initialize
the array elements each pass through the for() loop. But they are being
set to 0.
Here is the test program:
Code: |
#include <18F452.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
int1
skipmeK[96]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
void setskipK (int1 prx , unsigned int8 t) {
unsigned int8 q;
if (prx) skipmek[t]=0; // inverts prx
else skipmek[t]=1;
printf("InDeX %u :",t);
for (q=0; q<12; q++){
if (skipmek[q]) printf("1,");
else printf("0,");
}
printf("\r\n");
}
//======================================
void main(void)
{
int8 t;
for(t=0; t<12; t++)
setskipK(1, t);
while(1);
}
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Fri Jul 27, 2012 3:54 am |
|
|
As a comment, why not just use:
skipmek[t]=!prx;
There have definately been some oddities with int1 and arrays. However simple one dimensional arrays do seem to be OK.
I tried it as:
Code: |
#include <18F452.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
int1
skipmeK[96]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
void setskipK (int1 prx , unsigned int8 t) {
unsigned int8 q;
skipmek[t]=!prx;
printf("InDeX %u : ",t,);
for (q=0; q<12; q++) {
printf("%1d ", skipmek[q]);
}
printf("\r\n");
}
//======================================
void main(void) {
int8 t;
for(t=0; t<12; t++)
setskipK(1, t);
while(1);
}
|
and it merrily works with every version I have tried. 4.099 and up...
Best Wishes |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Fri Jul 27, 2012 10:27 am |
|
|
Stupid me .... this is a small part of a program that uses 85% of a 18f4525
AND I had reduced the code I posted w/o enough care.
This was actually the old core
Code: |
if (maxchannel){
if (prx) skipmek[t]=0; // inverts prx
else skipmek[t]=1;
}
|
maxchannel is a global retrieved from flash storage
and I was forgetting to call the flash readback function
such that maxchannel was =0 when I tried it with 4.135
However I do very much appreciate that I was able, with outside help, to overcome the mental block and solve this.
Sincere thanks and an apology for wasting the time of others
when I should have been more thorough myself. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|