Hi Folks,
There does seem to be a bitfield problem. We tried splitting the field
CCC into 8 and 4, and that did not help. Anybody have any thoughts?
Thanks,
Garst
--- Begin Message ---
Hi garst.... i am having problem with the CSD structure...
I was going to post it on the mailing list... i thought i might ask you
first.... i think it might be a bug.....
read below....
---------------------------------------------------------
Hi,
I am running into a problem using bit operations in C structures. The compiler
doesn't seem to produce the proper code to access the bits.... anyone have
this problem before...? is this a bug..? See the structure below....
I am trying to access csd.READ_BL_LEN
which are bits 44-47 according to the structure... (starting from bit zero at
top)
but when compiled and loaded on the MSP430... i have verified using debugging
output that it is actually showing bits 40-43...
essentially I want to read the low nibble of the 5th byte from top.... but
it is giving me the high nibble of the 5th byte from top....
To verify, ... i changed unsigned CCC:12 to unsigned CCC:8 ... which
removes 4 bits..... therefore shifting the everythihg 4 bits up.... then
csd.READ_BL_LEN starting showing the right value...
also the low nibble of buff[5] shows the exact value that i should be
getting in csd.READ_BL_LEN....
union reg16b_t {
struct csd_t {
unsigned CSD_STRUCTURE:2; //
unsigned SPEC_VERS:4; // Version
unsigned R1:2; // reserved
unsigned TAAC:8; // Read Access Time
unsigned NASC:8; // Read Access Time in CLK cycles
unsigned TRAN_SPEED:8; // Max Date Transfer Rate
unsigned CCC:12;// shout be f4 Card Command Class
unsigned READ_BL_LEN:4; // Max. Read Data Block Length
unsigned READ_BL_PARTIAL:1; // Partial Blocks for Read Allowed
unsigned WRITE_BLK_MISALIGN:1; // Write Block Misalignment
unsigned READ_BLK_MISALIGN:1; // Read Block Misalignment
unsigned DSR_IMP:1; // DSR Implemnted
unsigned R2:2; // reserved
unsigned C_SIZE:12;//Device Size
unsigned VDD_R_CURR_MIN:3; //Max. Read Current @Vdd Min.
unsigned VDD_R_CURR_MAX:3; //Max. Read Current @Vdd
unsigned VDD_W_CURR_MIN:3; //Max. Write Current @Vdd Min
unsigned VDD_W_CURR_MAX:3; //Max. Write Current @Vdd
unsigned C_SIZE_MULT:3; //Device Size Multiplier
unsigned SECTOR_SIZE:5; //Erase Sector Size
unsigned ERASE_GRP_SIZE:5; //Erase Group Size
unsigned WP_GRP_SIZE:5; //Write protect group Size
unsigned WP_GRP_ENABLE:1; //Write protect group Enable
unsigned DEFAULT_ECC:2; //
unsigned R2W_FACTOR:3; //Read to Write speed factor
unsigned WRITE_BL_LEN:4; //Max. Write Data Block Length
unsigned WRITE_BL_PARTIAL:1; //Partial blocks allowed 0
unsigned R3:5; //Reseved
unsigned FILE_FORMAT_GRP:1; //File format of selected Group
unsigned COPY:1; //Copy Flag (OTP)
unsigned PERM_WRITE_PROTECT:1; //Permanent write protection
unsigned TMP_WRITE_PROTECT:1; //Temporary write protection.
unsigned FILE_FORMAT:2; //File format of card
unsigned ECC:2; //ECC code
unsigned CRC:7; //CRC
unsigned STOP:1; //always 1
}csd;
unsigned char buff[16];
};
--- End Message ---