Struggling with Nano code

Hi folks, I am really struggling to get a project to do something I want.
Basically, I have an OLED display, BME module to measure humidity, but I also want to output a 108kHz PWM signal.
Here is the problem - there is a direct conflict because the Wire code uses timer1, and I need this to generate the PWM signal!

I am thinking the only way round this is to find a processor with two 16 bit timers?

I tried softwire but not convinced SSD1306 is compatible,,,

I can show the code if necessary but unless someone has a clever idea without interrupting PWM output I suspect this might be a hardware limitation as opposed to software...

Thanks

There are different Nano's so which one do you have exactly

Not much experience with the Nano, but I assume it has more than one timer so if you move the PWM to another PWM pin might solve this.

Google gave me

which states

Arduino Nano has 3 Timers and 6 PWM output pins. The relation between timers and PWM outputs is:
Pins 5 and 6: controlled by timer0
Pins 9 and 10: controlled by timer1
Pins 11 and 3: controlled by timer2

So there is an option to switch timer, don't know if the other timers can do the 108 kHz

hI rob, thanks for gettng back to me. It uses the Atmel 328 if that is any help.

Trouble with using the other timers for my PWM is I cannot get the high frequency I need.
I need to literately turn off the prescaler for timer1 to get the high frequency, as far as I can tell I cannot do this with timers 0 or 2.
If I am wrong please correct me.

I am thinking of using a PIC micro on the output of the Atmel. Basically Atmel turns on a 12f1840 which I can then use to generate the PWM, but I'd prefer to do this with a single IC, and I cannot program pics in C as yet, only in assembly LOL

Which wire code do you use? I don't think the standard Arduino Wire.h uses timer 1

It's only what I read on google, and when I change the timer1 settings, I lose all I2C comms with displays sadly

Not in Arduino's AVR core it doesn't. Examine the library source for yourself.

Without even a link to back that up, it's not even hearsay.

Nether Timer1 nor Tim0 Tim2 allowed you to produce a 8bit 108khz PWM on atmega328

Can you post code demonstrating the problem, or at least the code you use to set up timer 1 for 108KHz PWM?

Hi, @mil24

Can you please tell us what your project is?
Why do you need 108KHz PWM output?

Thanks.. Tom.... :smiley: :+1: :coffee: :australia: