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

Unable to printf an int16 on pic12f509

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



Joined: 25 Aug 2008
Posts: 5

View user's profile Send private message

Unable to printf an int16 on pic12f509
PostPosted: Mon Aug 25, 2008 6:15 pm     Reply with quote

I am unable to printf an int16 on pic12f509 in decimal but it is ok in hex.

I can printf in hex with a %lx

but when I get to the loop printing decimal it prints the Hello World once and then just garbage from then on.

compiler version 4.073

Hummm....


program follows
Code:
**********************************************
#include <12f509.h>
#fuses INTRC,NOWDT,NOPROTECT, NOMCLR
#use delay(clock=4000000)
#use rs232(baud=2400, xmit=PIN_B0, rcv=PIN_B1,ERRORS)

main()
{
int16 x = 0;
   while (x < 32)
   { 
      x ++;
      delay_ms(250);
      printf("Hello world %lx\r\n",x);
   }
   x = 0;
   while (x < 32)
   { 
      x ++;
      delay_ms(250);
      printf("Hello World %ld\r\n",x);
   }
return 0;
JB



Joined: 25 Aug 2008
Posts: 5

View user's profile Send private message

it works on a 18f4550
PostPosted: Tue Aug 26, 2008 10:47 am     Reply with quote

this code works

Code:

#include <18f4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN,NOPBADEN
#use delay(clock=48000000)
#use rs232(baud=2400, xmit=PIN_B7, rcv=PIN_B6,ERRORS)

main()
{
int16 x;


   x = 0;
   while (x < 32)
   { 
      x ++;
      delay_ms(250);
      printf("Hello world %lx\r\n",x);
   }
   x = 0;
   while (x < 32)
   { 
      x ++;
      delay_ms(250);
      printf("Hello World %ld\r\n",x);
   }
return 0;
}
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