MMC date and time

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Ruud van Zuidam
Flowcode V4 User
Posts: 2
Joined: Wed Dec 01, 2010 7:54 am
Location: netherlands
Contact:

MMC date and time

Post by Ruud van Zuidam »

If the String_filename = "Istec" + ".txt" + "Date_time"
And this is placed in FAT16 Create File.
How to activate date and time, and where to fil in?
DS1307 works wel in my software.

C++ index FAT16 Create File show MX_FILE_CREATETIME
How to turn this in a String command?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MMC date and time

Post by Benj »

Hello,

The current FAT component hard codes the file creation time and date as the compilation time and date.

To get around this you will have to edit the create file routine using code customization.

In the Create file function you will see the following section of code.

Code: Select all

				Write_Byte_To_Buffer((i * 32) + 11, 0x20);						//File Attribute
				Write_Byte_To_Buffer((i * 32) + 12, 0x18);						//Reserved for NT
				Write_Byte_To_Buffer((i * 32) + 13, 0);							//Creation time
				Write_Byte_To_Buffer((i * 32) + 14, MX_FILE_CREATETIME);
				Write_Byte_To_Buffer((i * 32) + 15, MX_FILE_CREATETIME >> 8);
				Write_Byte_To_Buffer((i * 32) + 16, MX_FILE_CREATEDATE);		//Creation date
				Write_Byte_To_Buffer((i * 32) + 17, MX_FILE_CREATEDATE >> 8);
				Write_Byte_To_Buffer((i * 32) + 18, MX_FILE_CREATEDATE);		//Access date
				Write_Byte_To_Buffer((i * 32) + 19, MX_FILE_CREATEDATE >> 8);
				Write_Byte_To_Buffer((i * 32) + 20, 0x00);
				Write_Byte_To_Buffer((i * 32) + 21, 0x00);
				Write_Byte_To_Buffer((i * 32) + 22, MX_FILE_CREATETIME);		//Modified time 0 no modification entry
				Write_Byte_To_Buffer((i * 32) + 23, MX_FILE_CREATETIME >> 8);
				Write_Byte_To_Buffer((i * 32) + 24, MX_FILE_CREATEDATE);		//Modified date
				Write_Byte_To_Buffer((i * 32) + 25, MX_FILE_CREATEDATE >> 8);
Where CREATEDATE is the hard coded date and CREATETIME is the hard coded time.

You could replace the hard coded definitions with variables from Flowcode. eg a variable called time in Flowcode would be called FCV_TIME in the C code.

From doing a Google search of the FAT format I have come up with this bit of info regarding the date and time parameters.

Time (5/6/5 bits, for hour/minutes/doubleseconds)
Date (7/4/5 bits, for year-since-1980/month/day)

Both time and date will have to be INT type variables in Flowcode.

Let me know how you get on.

Ruud van Zuidam
Flowcode V4 User
Posts: 2
Joined: Wed Dec 01, 2010 7:54 am
Location: netherlands
Contact:

Re: MMC date and time

Post by Ruud van Zuidam »

Hello,
Time and date still dont work.
To vill in the variable use box FAT Create lile and take ,, Temp16.AsInt = %a_FILE_CREATEDATE;,,
What to use =FILE_CREATEDATE or CREATEDATE or DATE.
How to put it in a C box.
Do you know the ansher..

Greatings ruud

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MMC date and time

Post by Benj »

Hello,

If the time and date are flat out not giving valid values then I would advise using the custom code to switch this code in the defines section.

Change

Code: Select all

#define %a_FILE_CREATEDATE		%l
#define %a_FILE_CREATETIME		%k
To this.

Code: Select all

#define %a_FILE_CREATEDATE		%k
#define %a_FILE_CREATETIME		%l
Once you have done this the fixed time and date should work.

If you then need to change the time and date then you can do so by changing the code above to this.

Code: Select all

MX_UINT16 %a_FILE_CREATEDATE		%k
MX_UINT16 %a_FILE_CREATETIME		%l
You can then reference the time and date variables in Flowcode using a C icon.

Firstly compile to C and have a look at the output C file to see what %a is being passed through as. Then use this in your C icon.

Here is an example of the C code in a Flowcode C icon referencing Flowcode variables datevar and timevar.

Code: Select all

FAT_1_FILE_CREATEDATE = FCV_DATEVAR;
FAT_1_FILE_CREATETIME = FCV_TIMEVAR;

Post Reply