|
|
View previous topic :: View next topic |
Author |
Message |
JB
Joined: 25 Aug 2008 Posts: 5
|
Unable to printf an int16 on pic12f509 |
Posted: Mon Aug 25, 2008 6:15 pm |
|
|
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
|
it works on a 18f4550 |
Posted: Tue Aug 26, 2008 10:47 am |
|
|
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;
} |
|
|
|
|
|
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
|