View previous topic :: View next topic |
Author |
Message |
ENGIMK Guest
|
problem with pic18f |
Posted: Thu Mar 29, 2007 1:59 pm |
|
|
i use pic18f2221 and pic c v 4.013
when i make array of int16 or int32 and try to read it it read false data
i do it in simulator and i found that either the data is shifted in ram or he read from the next address from the variable i want to read
i try pic c v 4.023 the same thing happen |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 29, 2007 2:09 pm |
|
|
Post a small test program. Then I can install that compiler version
and look at the problem. |
|
|
ENGIMK Guest
|
THERE IS THE CODE |
Posted: Thu Mar 29, 2007 2:13 pm |
|
|
#include <18F2221.h>
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
unsigned int32 step[3];
unsigned int32 remain[3];
void main()
{
unsigned int8 index;
for(index=0;index<3;index=index+1)
{
step[index]=10;
printf("index%d step=%lu\n",(byte)index, step[index]);
}
for(index=0;index<3;index=index+1)
{
remain[index]=10;
printf("index%d remain=%lu\n",(byte)index,remain[index]);
}
while(1)
{
output_high(pin_a0);
for(index=0;index<3;index++)
{
printf("index%d remain=%lu step=%lu\n",(byte)index,remain[index],step[index]);
output_low(pin_a0);
remain[index]=remain[index]-step[index];
if(remain[index] < step[index])
remain[index]=remain[index]+10;
}
}
}
I TRY IT ALSO ON PIC C V 3.249 BUT SAME THING HAPPEN
PRINTF SEND STEP=0 INSTEAD OF 10; |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 29, 2007 2:25 pm |
|
|
I compiled it with vs. 3.249 and ran it in the simulator for MPLAB vs. 7.20
and I got this:
Code: |
index0 step=10
index1 step=10
index2 step=10
index0 remain=10
index1 remain=10
index2 remain=10
index0 remain=10 step=10
index1 remain=10 step=10
index2 remain=10 step=10
index0 remain=10 step=10
index1 remain=10 step=10
index2 remain=10 step=10
etc.
|
What version of MPLAB do you have ? |
|
|
ENG.IMK
Joined: 29 Mar 2007 Posts: 3
|
|
Posted: Thu Mar 29, 2007 2:27 pm |
|
|
I USE PICSIMULATOR _________________ IMK |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 29, 2007 2:43 pm |
|
|
Here is their webpage, with screenshots at the bottom:
http://www.oshonsoft.com/pic18.html
I don't want to try to find or fix problems in their simulator.
I'm content to use MPLAB simulator. |
|
|
|