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 CCS Technical Support

Error on "printf" by using int16

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



Joined: 04 Feb 2012
Posts: 20

View user's profile Send private message

Error on "printf" by using int16
PostPosted: Wed Feb 15, 2012 10:06 am     Reply with quote

Hi.
I have a little problem I'm not able to solve on the coding. Hope the experts here can help me.

Below is my one part of coding:
Code:

void main()
{
   int16 heading;
   while(true)
   {
      heading=(HMC6352_read_heading())/10;
      lcd_init();
      printf(lcd_putc, "\fHeading degree:");
      printf(lcd_putc, "\n       %1u\r", heading);
     
      delay_ms(1000);
   }
}

However, the problem exists on the "printf"----> Printf format type is invalid. But I really need to use 16bit, so i used int16. Anyone can help me please.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 15, 2012 10:21 am     Reply with quote

If you press F11 when your project is open, the CCS onscreen Help files come up...locate the 'functions' and scroll down to printf..... it'll show you what you need to know...

I think you've mistyped the required format for an Int16.

lower case 'L's and 1s look very much the same depending on the font .
Jent



Joined: 04 Feb 2012
Posts: 20

View user's profile Send private message

PostPosted: Wed Feb 15, 2012 10:57 am     Reply with quote

Thanks informing...i really mistyped with 1 but actually is l...
actually I followed the previous post message from this ccs forum, and also intend to try this testing..

actually i did not really understand regarding this part:
Code:

printf(lcd_putc, "\n       %lu\r", heading);


if %u is regarding to unsigned decimal integer, but for %lu, i really couldn't understand. I checked the ccs manual, but discovered nothing..
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 15, 2012 1:03 pm     Reply with quote

Open CCS Help ( press F11) when project is open...

Goto Contents....

Open Data Definitions...

Open Basic Types.....

read what are the various types of data...

then

Goto Contents...

Open Built-in Functions...

Open All Built-in Functions...

Open printf()....

read.......


You should be able to see that an Unsigned INTeger is a value represented by 8 bits( a BYTE) of 0 to 255.
INT16 means a 16 bit integer( 2 bytes, a WORD in my world....).If Unsigned, 0 to 65535.
A Long Unsigned(Lu) can represent 0 to 65535, 16 bits of data, no negative numbers allowed.
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