External interrupt conflicting with tone

hello, I'm having conflict problems when a signal is captured by attachInterrupt(1,zero_crosss_int,RISING);

the tone, and everything that involves the timer ends up conflicting and disturbing the tone routine, I already changed the int0 port to int1 and the problem continues...

*I use nano.
*input signal is for dimmer, 120hz, it's ok.
*if you turn off the input signal everything works perfectly.

//dimmer
int ac = 6;
volatile int dimming; // dimming level(0-128) 3= 100%on - 124= 100%off


void setup() {
  // put your setup code here, to run once:
pinMode(ac,OUTPUT); // set ac load as output
attachInterrupt(0,zero_crosss_int,RISING);
//dimming=68; // 68 = 50% power
}


void zero_crosss_int() {
int mydelay = (65*dimming);
delayMicroseconds(mydelay);
digitalWrite(ac,HIGH);
delayMicroseconds(8.33);
digitalWrite(ac,LOW);
};


void loop() {
  // put your main code here, to run repeatedly:
dimming=100;

tone(12, 3000); // testing...
}

any advice for me to be able to use the tone(beep) along with the capture of the signal without interfering with the timer?

thx

Basically yes, this is expected behaviour.
An interrupt disrupts all timers and so there will be missing periods of time when using interrupts.

This in not an error, this is how it will happen.

Basically do not spend so much time in an interrupt service routine. Do not delay in them. The less time you spend the less disruption will occur.

What makes you think that this function takes in anything but integers?

0º ac line is 60Hz 1/60 = 0.01666 / 2 = 8.3usec. I need to use it this way
1º that's not the problem, if i leave the function empty the problem continues. Empty
2º delayMicroseconds is allowed inside ISR routines. with moderation
3º is part of the dimmer function.
4º yes, I know it needs to be fast and light, but this is for the TRIAC trigger. I could use a variable overflow counter, but it's already set for longer times, this code is just a clean test example, the original code I can't post (secrecy)

I didn't want to opt NOT to use the tone when the dimmer was on. I would like both to work together.

as a last resort i will have to do this.

I was thinking of using digitalWrite() and forgetting the ISR... the frequency is low and constant, 120Hz I believe can be used in the loop, what do you suggest?

Your math is incorrect by 3 orders of magnitude.

Buy an active buzzer. That only needs a voltage to produce a tone , so just attach it to a digital output pin to turn it on or off.

You may or may not need to have a delay of 2.8uS, but you are not going to get one, that function only accepts integers, that is whole numbers, no matter what you put in the brackets.

excellent idea, it really is possible that way, I had forgotten about the active buzzers. I came to think of external pwm circuits too. but this way is more practical and faster with the buzzer active.

ok, This function is not mine, I readily found it on the internet. however I already tested it and it works perfectly, the range goes from 0 (100% 0º = fullpower) to 124(0% 180º = off), 68 (50% 90º = midpower)
I checked on the oscilloscope this data.

I can remove this broken number and put integer, this value is only for triggering the Triac

I'm going to try to improve this with overflow, and remove the dependence on internal timers, because I use a lot of timers in this project, several tasks in parallel, rtc, communication with Nextion integral, etc, it's very complex.

thx guys

You can "readily" find all kinds of misinformation and nonsense on the internet.