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

Non accepted structure (bit field)

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



Joined: 31 Oct 2009
Posts: 2

View user's profile Send private message

Non accepted structure (bit field)
PostPosted: Sat Oct 31, 2009 1:39 am     Reply with quote

Hallo.
It's been some years i've been using CCS but i discovered (and actually needed) this forum just now.
Here is my problem.
There is this nice chip from GHI electronics that gives support for FAT16 and FAT32 with LFN and no hassle.
So my problem is i have to define a structure for this chip's time format and it goes like this

Code:
typedef struct
{
   int32 seconds2 : 5;   // seconds divided by 2
   int32 minutes : 6;
   int32 hours : 5;
   int32 day : 5;     
   int32 month : 4;
   int32 years_since_1980 : 7;
}FAT_Time_Structure;


this is taken directly from a manufacturer library.
Now CCS tells me that the second line is
"Number of bits out of range" while obviously it isn't.

By wild trials CCS accepts my declaration if TWO consecutive bit fields amount to 8 bits.
So if i had
5
3
6
2
4
4

it would compile.

But such an arrangment won't fit my needs.
Is this solvable? Or at least "workaroundable" ?

Thanks
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Oct 31, 2009 2:26 am     Reply with quote

Apparently CCS V4 8-Bit compilers still don't support bit fields across byte boundaries. The problem has been already known with V3 compilers.

Of course, a lot of register operations is involved when accessing a byte crossing bit field with a PIC16 or 18. That's why a programmer would leave it to the C compiler!

I fear, there's no easy workaround. You have to supply the bit field processing yourself, either as C or ASM code.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Oct 31, 2009 2:26 am     Reply with quote

Apparently V4 8-Bit compilers still don't support bit fields across byte boundaries. The problem has been already known with V3 compilers.

Of course, a lot of register operations is involved when accessing a byte crossing bit field with a PIC16 or 18. That's why a programmer would leave it to the C compiler!

I fear, there's no easy workaround. You have to supply the bit field accesses yourseff, either as C or ASM code.
johnnyst



Joined: 31 Oct 2009
Posts: 2

View user's profile Send private message

PostPosted: Sat Oct 31, 2009 3:10 am     Reply with quote

Thanks FvM.
By the way, since I read a discussion in which you chimed in...
Can you give me some help with a GPS?
I have a qstarz BT-810, I tried to send commands on the com port but it does not answer nor change.
What kind of command set should I use?
It has an MTK chipset, I tried MTK proprietary commands to no avail.
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