Page 1 of 1

Use device file in code

Posted: Tue Jan 28, 2014 3:46 pm
by JFinlayson
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)

Re: Use device file in code

Posted: Wed Jan 29, 2014 12:48 am
by JonnyW
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

Re: Use device file in code

Posted: Wed Jan 29, 2014 10:20 am
by JFinlayson
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.

Re: Use device file in code

Posted: Wed Jan 29, 2014 1:57 pm
by Benj
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 347 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.