Jump to content

User functions and MIOS background loop


Guest pkstone
 Share

Recommended Posts

Guest pkstone

Hi Thorsten,

I've been working on the Axe-Thing project I mentioned months ago - I asked you a question about scanning some custom switches from MIOS and you pointed me at USER_SR_Service_Finish.  I have a few more specific questions now that my custom design is almost finished, if you don't mind.

How much time would you estimate I have in a custom function called by the USER_SR_Service_Finish hook?  Time enough to scan 32 switches addressed by a couple of 4-bit counters?  

Can I manipulate RC0-3 directly in this function to control the counters?  Can I read J14 directly at each iteration of this 32-switch scan?  (I'm trying to keep SID pins available, but don't need any MF stuff).

(I have to use this method of scanning due to the design of the Axe-Thing's neck switches. I'll figure out a way to show you this part of my circuit if this question makes no sense).

In general, I'm curious about the timing of your background analog/digital scanning and update thread, and the impact the scanning of another 32 inputs in a custom USER_SR_Service_Finish routine would

have on other MIOS functions.  

Thanks!

Phil

Link to comment
Share on other sites

Hi Phil,

you've enough time to scan all switches in the USER_SR_Service_Finish hook - for comparison: this hook is also used by MIOS to handle with up to 64 rotary encoders, it takes 400 uS in worst case and loads the CPU by 40% (since the hook is called every milisecond)

RC0-3 can be controlled by the ISR. They are also controlled by the AIN driver, but only when the multiplexers are enabled

J14 is controlled by the SRIO driver, by setting bit "TRISD, 4" you can use it as input pin w/o conflicts.

Best Regards, Thorsten.

Link to comment
Share on other sites

Guest pkstone

Thanks, Thorsten.  I'm continually impressed and pleased by how versatile MIOS is.  

One question...

RC0-3 can be controlled by the ISR. They are also controlled by the AIN driver, but only when the multiplexers are enabled

I'm sorry, what's the ISR?  It looks like a PIC register, but I don't see it in my PIC docs - or the MIOS docs.  (I'm probably missing something obvious).

Thanks, Phil

Link to comment
Share on other sites

Hi Phil,

ISR means Interrupt service routine - a function which interrupts your mainprogram and therefore require some special care (see function description of USER_SR_Service_Finish)

Btw.: more detailed informations about dedicated registers for mainprograms/ISR, and about shared registers:

Following registers are dedicated for mainprograms, they will not be automatically saved before an interrupt call:

TMP1...TMP5 and FSR0

Following registers are dedicated for interrupt service routines, they shouldn't be used by mainprograms:

IRQ_TMP1...IRQ_TMP5 and FSR2

Following registers are stored automatically by the interrupt handler before a hook will be called, and they will be restored before the interrupt will be finished - therefore they can be used by the mainprogram and by ISRs without conflicts:

FSR1, TBLPTRL, TBLPTRH, TABLAT, MIOS_PARAMETER1...MIOS_PARAMETER3

Best Regards, Thorsten.

Link to comment
Share on other sites

  • 2 years later...

Since MIOS V1.8, FSR2 is saved as well, and FSR0 is saved by the C wrapper

Most of the older docs are inconsistent in the meantime, I know... biggest problem is, that all ISR related comments in the main.asm file are not correct anymore... just ignore it

Best Regards, Thorsten.

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...
 Share

×
×
  • Create New...