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

[Solved] Can't initialize int48

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



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

[Solved] Can't initialize int48
PostPosted: Sat Sep 28, 2013 12:06 am     Reply with quote

Compiler Version: 4.140
PIC: 18lf46k22

Why can't i initialize any variable greater than 48 bit in size?


Last edited by haxan7 on Sat Sep 28, 2013 12:36 am; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 28, 2013 12:16 am     Reply with quote

Why do you think an int48 data type is supported for that PIC and that
compiler version ? If I install vs. 4.140 and try to compile the program
shown below I get errors. It's not supported.
Code:

#include <18LF46K22.h>
#fuses INTRC_IO, NOWDT
#use delay(clock=4M)

int48 temp;

//===============================
void main(void)
{

while(1);
}
haxan7



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

PostPosted: Sat Sep 28, 2013 12:20 am     Reply with quote

PCM programmer wrote:
Why do you think an int48 data type is supported for that PIC and that
compiler version ?

I don't for sure, but i found this http://www.ccsinfo.com/content.php?page=syntax-functions.
It says that "int48" is for "PIC10 – PIC18 compilers only";
Ttelmah



Joined: 11 Mar 2010
Posts: 19470

View user's profile Send private message

PostPosted: Sat Sep 28, 2013 12:22 am     Reply with quote

int48, int64, float 64 etc., are _PCD_ features only. The PIC18/16 compiler does not support them.
You can initialise variables any size you want (structures etc.), but you would have to declare them, and generate the code to handle them.

I'd suspect CCS are intending to add them. I have asked in the past, particularly for the larger integer types. Historically, the V3, and V4 manuals don't mention them in pcb/pcm/pch, only listing them if you have pcd. With V5, then have been added to the manuals, but don't yet work.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 28, 2013 12:29 am     Reply with quote

Quote:
It says that "int48" is for "PIC10 – PIC18 compilers only";

No it doesn't. That note is for an Orange asterisk. That refers to the list of functions.

The data types such as int48 and int64 are marked with a pink asterisk.
That note says:
Quote:
Items marked with * are for 24-bit parts only.

Which is not for your PIC.

This colored asterisk stuff is crazy. CCS should have used numbered
superscripts, which is the way Microchip does it in their data sheets.
haxan7



Joined: 27 Jul 2013
Posts: 79

View user's profile Send private message

PostPosted: Sat Sep 28, 2013 12:37 am     Reply with quote

Thanks a lot guys. I was going to store phone number in an int, i guess i will have to use char array instead.
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Sat Sep 28, 2013 12:44 am     Reply with quote

Why not use a struct and store area code and number seperate. That way you can still use ints and save on ram.

Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19470

View user's profile Send private message

PostPosted: Sat Sep 28, 2013 1:24 am     Reply with quote

The manual inside the compiler, for V5, doesn't distinguish the types at all.

If you open the page 'basic and special types', no mention is made of what compilers can support what types. Given this is the PCB/M/H manual (not the PCD one), it really is designed to confuse...

Have to agree on the structure though.

Best Wishes
mcr1981



Joined: 27 Oct 2010
Posts: 28

View user's profile Send private message

About int48, int64, float48 and float64
PostPosted: Thu Jan 16, 2014 1:18 am     Reply with quote

Looks like I have some issue with this too Mr Ttelmah.

I'm moving to PCD from PCH (using MPLAB IDE, now MPLAB X).

I can see in the device file support for longer integers and floats:

Code:

#if (!defined(__PCD__)||defined(__ISNT_CCS__))
#define _bif
#define int8 char
#define int16 int
#define int32 long
#define int48 long
#define int64 long long
#define float32 float
#define float48 float
#define float64 double
#define int1 char

#endif


I'm using a simple program to declare variables and see their length. However, MPLAB X only shows 32 bit variables (four Bytes) for long long (int64) and double (float64).

I might be using it wrong since I'm new to PCD, but I think I'm right; unless you have to declare something to specify that you want this to compile for a PCD device other than the header file of the device.


I had some trouble with an LCD connection but got it working. Printed some info to it (float) and was not what I expected.

1/3 = 0.33 and the LCD showed 0.00; forced 1.0/3.0 and showed it correctly.

I do understand that sometimes you need to promote a variable or be specific about the operation you want, so I made a little program to test this in MPLAB X and to my surprise there were no 64 bit variables (you are right about the Data Definitions in the PCD manual).
Ttelmah



Joined: 11 Mar 2010
Posts: 19470

View user's profile Send private message

PostPosted: Thu Jan 16, 2014 2:19 am     Reply with quote

What that code does is say that on non PCD compilers, treat an int48, _as_ a long, to prevent syntax errors, and the same for the other types.

The types are _native_ on PCD, and the code section you post won't be used.

When you select the variable and create the 'watch'. Right click on it and select 'properties'. You can then select the size, and format. It is just that the defaults in MPLAB are for the smaller sizes.

Best Wishes
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Thu Jan 16, 2014 5:00 am     Reply with quote

haxan7 wrote:
I was going to store phone number in an int, i guess i will have to use char array instead.


Phone "numbers" are not numbers, but include symbols and are generally formatted. They often have leading zeros and are specific lengths. They are strings, not numbers. A typical phone number where I am is something like (I made this up, it's not a real phone number):

02973 231765

Also, especially on older telephone systems, other symbols were/are used to give pauses in the dialling to allow the phone system to do its thing. For example, from here at work, which is in the same area code, I'd dial:

9,231765

where the comma represents a pause to wait for the "outside" line.

for international use that would be:

+44 (2973) 231765

You cannot use ints for these. You need to treat it as a string, i.e. an array of char.
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