1

I learned from answers here that pinMode(0, OUTPUT) is a platform-independent equivalent of DDRB = 1<<DDB0, on the ATTiny85.

Are there platform-independent functions for the following?

TCCR0A = 2<<COM0A0 | 2<<COM0B0 | 3<<WGM00;
TCCR0B = 0<<WGM02 | 1<<CS00;
TCCR1 = 0<<PWM1A | 0<<COM1A0 | 1<<CS10;
GTCCR = 1<<PWM1B | 2<<COM1B0;

Explanation of above code here. These calls enable FastPWM.

I checked the Arduino API reference, but not sure which are the equivalent to above. How to determine?

5

It is highly unlikely there would be direct 1:1 functions that implement such discrete operations. Simply because such operations are pretty unique to a single family of microcontrollers. They are too low-level for an API to even consider wanting them.

Instead, there are higher level functions which may, if the chip requires it, include those operations.

The operations you list are all related to PWM, so the higher level function that would encompass them would be analogWrite().

  • Man, you're good! But, these fx are specifically to enable FastPWM. Any higher-level calls for FastPWM? thx! – johny why Jan 5 '18 at 20:55
  • 1
    Not that I am aware of in the standard Arduino API. We have them in the chipKIT API, and it's something we'd like to see adopted upstream, but alas not yet. – Majenko Jan 5 '18 at 20:59
  • sweet! Chipkit is for programming AVR's with Java? – johny why Jan 5 '18 at 23:57
  • What on earth would give you that impression? chipKIT is for programming PIC32s with the Arduino API. – Majenko Jan 5 '18 at 23:58
  • Why on Earth would you mention a pic library in an Arduino question? – johny why Jan 8 '18 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.