So, I create a better solution IMHO for the ATTiny code. As we'll only have one source of interrupt, this code should be safe, but I have no way to test before my sBitx v2 and AVR programmer arrives. Here is the PR:
73,
rafael PU2UIT
toggle quoted message
Show quoted text
On 5/3/23 10:56, Rafael Diniz wrote:
Right. That is what I thought... we might not want too much code inside the interrupt handler function. We could also use a flag written by any atomic ATMEL instruction and use a double buffer, if the flag is up, for eg, we use buffer 2, if the flag is down, buffer 1.
Anyway, the code you proposed disabling interrupts should be ok, as reading about the I2C, it seems that if we turn off interrupts just a bit, we'll not lose the I2C interrupt, as it will just be delayed. I need to read the ATMEGA datasheet to make sure about this (and of course, testing also).
Buuut... As the ATTiny85 might not have any other interrupt (if we remove that delay()), I also would consider reading the two ports and writing the answer inside the interrupt handler, if it all goes well... then problem solved.
: )
Rafael
On 5/3/23 06:08, Steve Beckman wrote:
Rafael - Not sure that we would want to have the extra code being executed after the interrupt gets called but before the message is written back out via i2c. I agree that it would eliminate the need to take steps to make the array fill atomic.
Soon we will be able to try it and see what happens.
73; Steve, N3SB