VM-Event

I did earlier create named Event’s that could be called with a Raise statement. The last example created an Event digitalIn[2] where the “name” is a declared object register and the event is automatically called if C or PLAIN assembly changes that exact bit.

Event digitalIn[2]
            // ...
End

 I like the concept, of Automatic events, but I need to let the syntax mature a little. Is this event to be called before or after we change the bit? Is it to be called only on Write or also on Read? And what about parameters?

Event DI() On digitalIn[2..3]
            // 
End

The modified syntax above name the event to enable it to be raised or called, and it add the On keyword to allow allocation of automatic events.

Event DI() on digitalIn[2..3] After Write
            // 
End

This add the syntax After|Before Read|Write allowing us to control how it is called. Adding parameters is also straight forward since we have a name and a (). Parameters will either be the same as declared in the C implementation or none at all – need to work on this part.

Event On Ch4.AnalogueIn
            //
End

 The event above is however a challenge because it is connected to an ADC that very well might be sampled at 2.4Mhz. Any attempt on calling an event at that frequency will overload our MCU, so we need a buffer mechanism if we actually want to sample this fast, or add a filter on the ADC. A filter in this case is a max frequency and a threshold requiring a minimum change before it is raised as an event. These capabilities needs to be added to the C interface – I don’t think I want to control this on the Event declaration – not sure.

Leave a Reply