Cheers Crenn
I have been working through the reference manual, (the beefy 1023 document that it is..). not datasheet as I said. I've got it complementing now, although I need to declare both pins as PWM using the pinMode() command, then bitbash away in the registers (its not very elegant at this stage).
My issue now is that the complemented output is changing, where the non complement is static, as though the compare value is incrementing for the complemented channel, once it exceeds the threshold. I'll think about it some more and post when I work it out, it probably trivial.
For now I'll post the code, Ive set and cleared individual bits explicitly so I could keep track of what was being changed. It may help someone else looking at this.
void setup(){
HardwareTimer timer8 = HardwareTimer(8);
// timer8.pause();
timer8.setPrescaleFactor(1);
timer8.setOverflow(65535/4);
timer8.setCount(0);
// timer8.refresh();
pinMode(13, PWM); //Not sure what this is seting in the reg's
pinMode(55, PWM);
timer_dev *t = TIMER8; //refers t to Timer 8 memory location, how to read this back?
timer_reg_map r = t->regs;
bitClear(r.adv->CR1,0); //disable clock to set centre alligned mode
bitClear(r.adv->BDTR,8); //unnlock BDTR register, could probably keep lock level 1 on
bitClear(r.adv->BDTR,9);
bitClear(r.adv->CCER,0); // clear TIM8_CCER bit 0 to set CCMR bits
bitClear(r.adv->CCMR1,0); //This should configure channel1 of Timer8 as an output
bitClear(r.adv->CCMR1,1);
bitSet(r.adv ->CCMR1,4); //Set PWM mode2 channel 1 timer8
bitSet(r.adv ->CCMR1,5);
bitSet(r.adv ->CCMR1,6);
bitSet(r.adv ->CCMR1,3); //Set OCPE bit to enable auto reload register
bitSet(r.adv -> CR1,7); //Buffer reload register
bitSet(r.adv->CR1,5); //These two bits specify one of three centre aligned PWM options
bitSet(r.adv->CR1,6); //
bitSet(r.adv->EGR,0); //initialise all registers
bitSet(r.adv->CCER,0); //this should enable complimentary outputs
bitSet(r.adv->CCER,2);
bitSet(r.adv->BDTR,11); // OSSR bit
bitSet(r.adv->BDTR,15); // MOE bit Cleared by software, probably dont need to set
bitSet(r.adv->CR1,0); //clock back on
}
void loop(){
pwmWrite(13, 15000); //should complement on pin55
}
Some of the bit operations are probably redundant due to the pinMode(), p340 and 307 of the STM32F reference manual give alot of info on the required registers