Title: Dude with Mmc_Fat_Library mikroC Post by: juliozv on May 21, 2013, 02:30:27 02:30 Hi,
I make a datalogger project, I use sensors like temperature, humidity and RTC, but I need to add the SD Card for keep the information. when I read the Mmc_Fat library of mikroC PRO but I don't understand well the next routine: Mmc_Fat_Assing( filename , file_cre_attr) * mikroC say file_cre_attr: file creation and attributs flags. Each bit corresponds to the appropriate file attribut: Bit Mask Description 0 0x01 Read Only 1 0x02 Hidden 2 0x04 System 3 0x08 Volume Label 4 0x10 Subdirectory 5 0x20 Archive 6 0x40 Device (internal use only, never found on disk) 7 0x80 File creation flag. If file does not exist and this flag is set, a new file with specified name will be created. in the part the "file_cre_attr" how is the configuraion of bits? in the example of mikroE has 0xA0 but I don't understand where this value. thanks for your time.. Title: Re: Dude with Mmc_Fat_Library mikroC Post by: bigtoy on May 21, 2013, 04:45:39 04:45 Hex 0xA0 is Binary 10100000, so bits 7 and 5 are set. In other words, "create a new file if the specified file name doesn't already exist", and "set the archive bit". The remaining bits are all clear, so it's not a read-only file, not hidden, not a system file, not a volume label, not a subdirectory, and not a device.
Title: Re: Dude with Mmc_Fat_Library mikroC Post by: sam_des on May 21, 2013, 04:59:01 04:59 Hi,
I have never used the mikroC, but I guess you can OR the flags to assign multiple attributes to file. e.g. 0x01 | 0x02 -> 0x03 -> Read Only + Hidden 0x80 | 0x10 | 0x04 -> 0x94 -> Create file if doesn't exist, Make it(existing or new) System Subdirectory. Of course, some of the combinations may be invalid. It seems mikroC library is FAT16 implementation, you can get lots of info about it on net. Hope this helps, sam_des Title: Re: Dude with Mmc_Fat_Library mikroC Post by: pablo2048 on May 21, 2013, 06:33:29 06:33 Just look into elm-chan fatfs module (http://elm-chan.org/fsw/ff/00index_e.html) - i suggest to define attributes in this way:
Code: #define ATTR_READONLY (0x01) Code: Mmc_Fat_Assing(filename, ATTR_READONLY | ATTR_HIDDEN...) Title: Re: Dude with Mmc_Fat_Library mikroC Post by: juliozv on May 21, 2013, 01:16:34 13:16 ;D, yes it's a OR function:
In this case file_cre_attr = 0xA0, means Archive and File creation flag, because, 0xA0 = 0x20 + 0x80 (0x20 -> Archive, 0x80 -> File creation flag). Just look into elm-chan fatfs module (http://elm-chan.org/fsw/ff/00index_e.html) - i suggest to define attributes in this way: Code: #define ATTR_READONLY (0x01) Code: Mmc_Fat_Assing(filename, ATTR_READONLY | ATTR_HIDDEN...) it's a good generic FAT file system module and similar of mikroC. ;) |