Using channels B and C of PWM timers

Hi,

I'm just trying to get a handle on how to use the extra pins of the PWM timers (have a Mega 2560) and I'm running into a bit of trouble with getting the B and C channels to work (A works fine).

Here's my test code:

#include <Arduino.h>

uint8_t pulse, channels;

void setup() {
  channels = (1 << COM3A1) | (1 << COM3B1) | (1 << COM3C1);
  pinMode(13, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(5, LOW);
  
  TCCR3A = (1 << WGM31);
  TCCR3B = (1 << WGM33) | (1 << CS30);
  
  int pulse = 16000 / 36 / 2; // 36 megahertz
  ICR3 = pulse;
  OCR3A = pulse / 3;
}

void loop() {
    digitalWrite(13, LOW);
    TCCR3A = (1 << WGM31);
    
    delay(500);
    
    digitalWrite(13, HIGH);
    TCCR3A |= channels;

    delay(500);
}

Using this code, I can see pin 5 (channel A) working fine, it pulses for half a second, and then goes quiet for half a second.

However when I hook up to channel B and C, they're just sitting there doing nothing.

From what I've been able to discern from my reading, setting the COM3B1 bit in TCCR3A should tell it to send a non-inverted signal to pin 2 (the same as I'm getting on pin 5).

However this is not doing this and despite all the combinations I've tried, I can't work out why not. Is there something really simple that I'm missing here? I have noticed that a LOT of the example code that's out there on the net only ever use the channel A pin for each timer. At this point I'm starting to wonder if there's a reason for that.

Thanks for reading.

Try writing the required PWM values to the OCR3B and OCR3C registers.

You sir, are a gentleman and a scholar.

So simple. It works like a charm (and I feel like a twit).

Thank you for taking the time out of your day to reply.