Lets solve this once and for all: How to PWM at a certain frequency

I always see questions about this and it troubles me that I'm not able to answer them. How do you get an IR emitter to PWN at 38KHz? Without using a library or a timing chip. Shouldn't there be a way to analogWrite it to a certain frequency ? This goes for any LED, not just IR.

How this is achieved is different depending on the chip, just as it is for controlling the duty cycle of a PWM signal. It's not even the same for all AVR chips, never mind SAMD21, ESP8266/32 and all the other types of chip used in Arduino compatible boards these days.

So the only way to make it the same for most of all Arduino is to make it part of the Arduino core, so that it can be implemented differently for each chip, but those differences hidden from us, the end users.

Unfortunately, it may already be too late to achieve a consistent way. For example, Teensy boards have analogWriteFrequency(), while ESP boards have analogWriteFreq().

Whilst understanding that there are hardware differences between the various microcontrollers that can be programmed from the Arduino IDE, there is a commonality, timing wise, for;

Delay.
Serial Baud rate.
SPI Clock rate (I think)
I2C Clock rate (I think)

So whilst it might be possible to do the same for PWM, who would do all the work, across all the different microcontrollers to make it a reality.

Is this a case of 'someone else should' ?

it troubles me that I'm not able to answer them

No surprise there. You haven't bothered to read the material we linked in our responses to your other post on the same topic.

Do not double post.