View previous topic :: View next topic |
Author |
Message |
johnnyst
Joined: 31 Oct 2009 Posts: 2
|
Non accepted structure (bit field) |
Posted: Sat Oct 31, 2009 1:39 am |
|
|
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
|
|
Posted: Sat Oct 31, 2009 2:26 am |
|
|
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
|
|
Posted: Sat Oct 31, 2009 2:26 am |
|
|
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
|
|
Posted: Sat Oct 31, 2009 3:10 am |
|
|
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. |
|
|
|