CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

dsPIC33, basic program, big problem...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
romelec



Joined: 14 Mar 2008
Posts: 1

View user's profile Send private message

dsPIC33, basic program, big problem...
PostPosted: Fri Mar 14, 2008 4:09 am     Reply with quote

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 Confused
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

View user's profile Send private message Send e-mail MSN Messenger

try...
PostPosted: Fri Mar 14, 2008 7:43 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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