I am generating a 100 kHz interleaved signal (image attached) with 80 % duty cycle using the following code for Arduino UNO. However, when I measure the signal frequency with oscilloscope, I get 48 kHz only. If I try to reduce the delayMicroseconds() the maximum achievable frequency is 61 kHz.
Why this is happening? Either with UNO I cannot get more than 61 kHz or the oscilloscope measurements are incorrect... I could figure out the reason. Please help me with this issue.
This function works very accurately in the range 3 microseconds and up. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times.
gfvalvo:
Not when you use Timer 1 in Mode 10. That allows you to set TOP via the ICR1 register.
Yes, you are absolutely correct. With some examples I have managed to get one of the required signals with the following code. How I can get the other phase-shifted signal?
void setup()
{
// Set PB1 to be an output (Pin9 Arduino UNO)
DDRB |= (1 << PB1);
The comments in your code are incorrect. With the register setting you posted, OC1A is inverting and OC1B is non-inverting.
Did you trying changing the duty cycle with the code I posted? Just enter '+' or '-' at the Serial Monitor (and maybe 'enter key' too) to change it up or down. See the code in the loop() function.
gfvalvo:
The comments in your code are incorrect. With the register setting you posted, OC1A is inverting and OC1B is non-inverting.
Did you trying changing the duty cycle with the code I posted? Just enter '+' or '-' at the Serial Monitor (and maybe 'enter key' too) to change it up or down. See the code in the loop() function.
I corrected the comments... just changed the code but forgot to update the comments.
I haven't changed the duty cycle with '+' or '-' at the serial monitor. I use it for driving MOSFETs with MC33152 for a DC-DC converter and need to keep 80% duty cycle for time being.