Page 4 of 4

Re: Component sfk 433 Mhz serial for Arduino, ext.

Posted: Wed May 25, 2022 9:35 am
by medelec35
Hi Jan.
I have found that if an interrupt enable is placed within another interrupt, it does indeed cause issues.
For example, it can restart all the code.
What I would do if I were you is to enable timer2 only once just below the enable INT0 enable icon .
Then just after the enable Timer2 icon, place a C code block with

Code: Select all

cr_bit(PIE4,TMR2IE);
which stops the interrupt from firing.
Use that c code to replace all the timer2 disable icons.
Then I would replace all the timer2 enable icons with a c code block containing

Code: Select all

st_bit(PIE4,TMR2IE);

Re: Component sfk 433 Mhz serial for Arduino, ext.

Posted: Wed May 25, 2022 12:46 pm
by jan.didden
Martin, thanks, I will see if I can get it to work that way.
I had a hunch that it had to do with (illegal?) overwrite of interrupt register contents, or possibly just a coding error in the register/bit name, but didn't know how to check that.
Martin mnfischer confirmed it indeed is an issue.
You have restarted me ;-)

Jan

Re: Component sfk 433 Mhz serial for Arduino, ext.

Posted: Wed May 25, 2022 12:59 pm
by mnfisher
Thanks Martin - a lot neater than my work round too I added a flag and restarted the timer on the main loop if not running.

Worked, but a bit clunky..

The interrupt rate given in the interrupt setup seems incorrect. By a factor of 4 - I had to set stated interrupt rate to 1/4 the desired rate.

Martin

Re: Component sfk 433 Mhz serial for Arduino, ext.

Posted: Wed May 25, 2022 2:20 pm
by medelec35
Hi Jan/Martin
Sorry, there was a typo in my code and I have corrected it.
The correct codes are

Code: Select all

cr_bit(PIE4,TMR2IE);
and

Code: Select all

st_bit(PIE4,TMR2IE);
The / should not have been present

I'm glad the information helped you to get restarted.

Thank you, Martin (mnfisher) for your great support to Jan and other members.
Your help is really appreciated by us all! :)

Re: Component sfk 433 Mhz serial for Arduino, ext.

Posted: Wed May 25, 2022 4:25 pm
by mnfisher
Thanks Martin,

That works perfectly. Not quite as straightforward as on the AVR chip but all's well etc...

This isn't quite the right topic so I'll post the code to the NEC IR topic...

Martin

Re: Component sfk 433 Mhz serial for Arduino, ext.

Posted: Thu May 26, 2022 7:37 am
by jan.didden
Martin (medelec), just to be sure, your code enables/disables the timer but does not reset or clear it, correct?

Jan

Re: Component sfk 433 Mhz serial for Arduino, ext.

Posted: Thu May 26, 2022 7:55 am
by mnfisher
It doesn't clear the timer (though for our/most purposes it doesn't matter)

Martin

Re: Component sfk 433 Mhz serial for Arduino, ext.

Posted: Thu May 26, 2022 9:02 am
by jan.didden
I really would like to thank Martin mnfisher publicly for his support to get this project up and running.
I'm pretty sure he doesn't have loads of spare time but nevertheless always willing to listen and help.
There's a very long list of PM's between him and me.
I vote to give him a lifetime free FC update ;-)

Jan

Re: Component sfk 433 Mhz serial for Arduino, ext.

Posted: Thu May 26, 2022 5:09 pm
by mnfisher
And thanks to Jan & Martin (medelec) too..

If possible I'd like a lifetime supply of spare time - there seems to be a lot less of it about with every passing year...

Martin