Jump to content

USER_Tick - Scan_Matrix


Recommended Posts

In TK's and QBas 8 x 8 and 16 x 16 keyboard Scan Matrix the SM_ButtonHandler is called from USER_Tick.

This is described in the MIOS Functions Reference as "This function called by MIOS in the mainloop when nothing else is to do"

A number of questions occur.

If called does the SM-ButtonHandler function perform once only?  Or can it perform several times ?

What happens if the function takes too much time?

Thanks in advance

Robin

Link to comment
Share on other sites

Hi Robin,

If called does the SM-ButtonHandler function perform once only?  Or can it perform several times ?

USER_Tick will be called by MIOS in an endless loop, so yes: it will be called several times until you power-off the core.

Beside of USER_Tick, several other handlers will be called consecutively, e.g. the DIN and AIN input checking routine, the MIDI parser, the MIOS_DISPLAY_Tick routine, etc... and once the execution of these handlers has been finished, the sequence re-starts at USER_Tick

This method is also called cooperative multitasking

So long the other handlers are idle (no DIN/AIN change, no incoming MIDI events, no LCD output, etc) USER_Tick will be called with a period of 20 uS, which is pretty fast! :)

What happens if the function takes too much time?

In this case, the other tasks will be blocked. The max. acceptable delay depends on your application.

There is only one strict requirement: it should never take more than ca. 20 mS, because if the MIDI parser is not called within this time span, the MIDI IN buffer could overrun

Note also: than longer USER_Tick takes, than longer the slack time of the other tasks

If my own applications, I'm trying to reduce the max. execution time of USER_Tick to less than 1 mS

If it takes longer, I program the functions which are handled by USER_Tick in a way that they will be processed step by step with each call of USER_Tick - example: when I'm checking if a new (of up to 8 ) BankStick has been connected to the core module, I'm only checking a single BankStick with each USER_Tick execution. I'm using a counter which is incremented and reset if >= 8 each time my BankStick handler is called, and this counter addresses the BankStick which should be checked. This easy method reduces the execution time of USER_Tick dramatically, and therefore improves the overall performance of the application.

Best Regards, Thorsten.

Link to comment
Share on other sites

Thanks Thorsten

If I understand your answer properly, the USER_Tick follows the other tasks you mentioned.  Then when USER_Tick is completed the other tasks will immediately  be restarted then followed by a second USER_Tick and so on until the system is closed down.

Best Regards Robin

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...