|
|
View previous topic :: View next topic |
Author |
Message |
romelec
Joined: 14 Mar 2008 Posts: 1
|
dsPIC33, basic program, big problem... |
Posted: Fri Mar 14, 2008 4:09 am |
|
|
Hi,
I am using a dsPIC33FJ256MC710, look at this small code:
Code: | void main()
{
int8 ind;
int8 tab[10];
fprintf(COM1,"test...\n");
delay_ms(500);
tab[0] = 3;fprintf(COM1,"tab[0]=%d\n",tab[0]);
tab[1] = 9;fprintf(COM1,"tab[1]=%d\n",tab[1]);
tab[2] = 16;fprintf(COM1,"tab[2]=%d\n",tab[2]);
tab[3] = 35;fprintf(COM1,"tab[3]=%d\n",tab[3]);
for(ind=0;ind<10;ind=ind+1)
{
tab[ind] = ind;
fprintf(COM1,"ind=%d tab[ind]=%d\n",ind,tab[ind]);
delay_ms(500);
}
} |
very basic and should not cause any problem, isn't it ?
so know let's have a look at the result
Code: | test...
tab[0]=6
tab[1]=6
tab[2]=6
tab[3]=6
ind=3 tab[ind]=54
ind=3 tab[ind]=0
ind=3 tab[ind]=0
ind=3 tab[ind]=0
ind=3 tab[ind]=0
ind=3 tab[ind]=0
ind=3 tab[ind]=0
ind=3 tab[ind]=0
ind=3 tab[ind]=0
ind=3 tab[ind]=0
ind=3 tab[ind]=0
at this point the message is always the same until i reset the pic |
if i use 16 bits integers:
Code: | test...
tab[0]=3
tab[1]=9
tab[2]=16
tab[3]=35
ind=0 tab[ind]=0
ind=1 tab[ind]=2
ind=2 tab[ind]=4
ind=3 tab[ind]=6
ind=4 tab[ind]=8
ind=5 tab[ind]=10
ind=6 tab[ind]=12
ind=7 tab[ind]=14
ind=8 tab[ind]=16
ind=9 tab[ind]=18 |
and 32bits !
Code: | test...
tab[0]=3
tab[1]=9
tab[2]=16
tab[3]=35
ind=0 tab[ind]=0
ind=1 tab[ind]=262148
ind=2 tab[ind]=524296
ind=3 tab[ind]=786444
ind=4 tab[ind]=1048592
ind=5 tab[ind]=1310740
ind=6 tab[ind]=1572888
ind=7 tab[ind]=1835036
ind=8 tab[ind]=2097184
ind=9 tab[ind]=2359332 |
Maybe you understand the problem, but me absolutely no
using microchip C30 it works of course very well.
Do you see a solution, except migrate my program to microchip compiler ?
(I have just sent a mail et the support)
Romain. |
|
|
murtis
Joined: 12 Aug 2007 Posts: 41
|
try... |
Posted: Fri Mar 14, 2008 7:43 am |
|
|
hi,
this is the float print but %d is using integer print
fprintf(COM1,"tab[3]=%d\n",tab[3]);
and also, ind and tab[10] is identificated as an integer number.
May be,
you can solve the problem if you are using the code written like below
printf(COM1,"ind=%d tab[ind]=%d\n",ind,tab[ind]);
and also, you should try 'putc' command. _________________ MurtiS |
|
|
|
|
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
|