Hello! Would you please help me with the following:
I'm using Teensy4.1 with latest teensyduino library. In a code, I'm running a function "myPeriodicFunction" every two millisecond, following way:
And this looks like working, function is running every two milliseconds.
Now I need to update some data structure for this function: change about 8 numbers, so myPeriodicFunction would use those new parameters. I need this from the "main", not from the interrupt. And I'd like to pass all the parameters "at once", not one by one.
What could be the correct way to do this? I do not want to disable all the interrupts in "main". Can I disable only just this ('low priority?') interrupt? And after I enable it, will "myPeriodicFunction" be called right after this (right after "enable_irq")?
Should I use "__NVIC_DisableIRQ" and if yes, how to do this correctly? Or, maybe better not to disable interrupts but use __STREXW, as I noticed in micros() function ? (But this latter case looks not safe sometimes.. like if "main" would constantly updating the structure, and then interrupt will occur, and it see that "structure is updating right now and what's next? looks like it may be that in this case irq (myPeriodicFunction ) will never use updated structure.)
Also I noticed that "void attachInterrupt(EventResponderFunction function, uint8_t priority=128)" does not use its "priority parameter.
Instead, there is a "SCB_SHPR3 |= 0x00FF0000; // configure PendSV, lowest priority"
How to correctly setup an interrupt with slightly higher priority then this one?
Best regards!
I'm using Teensy4.1 with latest teensyduino library. In a code, I'm running a function "myPeriodicFunction" every two millisecond, following way:
Code:
EventResponder er;
er.attachInterrupt(myPeriodicFunction);
MillisTimer mt;
mt.beginRepeating(2, er);
And this looks like working, function is running every two milliseconds.
Now I need to update some data structure for this function: change about 8 numbers, so myPeriodicFunction would use those new parameters. I need this from the "main", not from the interrupt. And I'd like to pass all the parameters "at once", not one by one.
What could be the correct way to do this? I do not want to disable all the interrupts in "main". Can I disable only just this ('low priority?') interrupt? And after I enable it, will "myPeriodicFunction" be called right after this (right after "enable_irq")?
Should I use "__NVIC_DisableIRQ" and if yes, how to do this correctly? Or, maybe better not to disable interrupts but use __STREXW, as I noticed in micros() function ? (But this latter case looks not safe sometimes.. like if "main" would constantly updating the structure, and then interrupt will occur, and it see that "structure is updating right now and what's next? looks like it may be that in this case irq (myPeriodicFunction ) will never use updated structure.)
Also I noticed that "void attachInterrupt(EventResponderFunction function, uint8_t priority=128)" does not use its "priority parameter.
Instead, there is a "SCB_SHPR3 |= 0x00FF0000; // configure PendSV, lowest priority"
How to correctly setup an interrupt with slightly higher priority then this one?
Best regards!