Use device file in code

A forum where Flowcode v6 user created components can be shared, discussed and reviewed.

Moderator: Benj

JFinlayson
Posts: 92
Joined: Mon Sep 23, 2013 4:33 pm
Has thanked: 5 times
Been thanked: 6 times
Contact:

Use device file in code

Postby JFinlayson » Tue Jan 28, 2014 3:46 pm

Hi
I was looking to create a component a counter, and use information as to what counters are available from the device file .BAS which should contain what timers are available how can I get this data and populate a list similar to when you insert an interrupt in a flowchart. I presume there is a way to access this data?

8)
The older the boy the bigger the toy

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 64 times
Been thanked: 306 times
Contact:

Re: Use device file in code

Postby JonnyW » Wed Jan 29, 2014 12:48 am

Hi.

I don't know what a .BAS file is or what format it is in, but you can use the SIM API calls to open a file and read its contents as strings, see: http://www.matrixmultimedia.com/wiki/in ... e=API_File

Once this is done, you can populate the list elements of a property which is set to be a list. See: http://www.matrixmultimedia.com/wiki/in ... etListItem and related articles.

The property can be hooked into using the property event: http://www.matrixmultimedia.com/wiki/in ... s.Property

Any changes you make to the appearance or details of your component can be done during this event.

I hope this gives something to go on. I think I have a simple example of this floating round at work.

Another alternative (if you would prefer) is to use a DLL to parse the BAS file and provide an API for Flowcode to hook into to enumerate the contents as strings. I think the RS232 Serial simulation stuff works in this way.

Cheers,

Jonny
These users thanked the author JonnyW for the post:
JFinlayson (Wed Jan 29, 2014 10:21 am)
Rating: 5.26%
 

JFinlayson
Posts: 92
Joined: Mon Sep 23, 2013 4:33 pm
Has thanked: 5 times
Been thanked: 6 times
Contact:

Re: Use device file in code

Postby JFinlayson » Wed Jan 29, 2014 10:20 am

Hi thanks for the quick reply,
I am trying to get information on the number of timers there are on a chip that is selected, and from this create a component to set timers as counters that is customisable. I have a lot to learn about flowcode 6 yet.
The older the boy the bigger the toy

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

Re: Use device file in code

Postby Benj » Wed Jan 29, 2014 1:57 pm

Hello,

Sounds like a great idea.

Attached here is the v6 source for the Target Chip component which currently does thinks like looking at the target definition file for things like the chip name, number of pins etc.

You could essentially take this and by referring to the XML branches in the FCDX definition file work out what timers are available, max rollovers etc. You can use a text editor like notepad or textpad to view the FCDX definition file to see what the layout and branch names are for the various peripherals.

ChipComponent.fcfx
(48.76 KiB) Downloaded 180 times


This blog post may help in detailing what's going on in the file.
http://matrixmultimedia.com/blog/?p=228

If you think that things are missing from the FCDX file then let us know. It would be nice to have the name of the timer count register so you can dynamically read or write the count using a component macro so I will get this on the list as something to add.

Let us know how your getting on.