I am using mode 4 CTC (Clear Timer on Compare) to generate input for a stepper motor driver chip. (A4988)
An ISR handles changing OCR1A for various speeds
The issue is that each timer compare toggles OC1A. However I need to generate pulses.
So my idea was to look at the pin state in the ISR and take no action if it is high. Then when it is low increment my step count and adjust speed if needed.
Of course I could write to the pin in the ISR but I would rather the hardware handle it to avoid jitter from other ISRs and atomic operations.
Quoting the datasheet
If one or both of the COM1A1:0 bits are written to one, the OC1A output
overrides the normal port functionality of the I/O pin it is connected to.
So clearly I can not write to the pin, but it seems that I should be able to read it. However this test code only spits out +. The o-scope says otherwise.
if (PORTB & (1<< PB1)) usart0_putc('+');else usart0_putc('-');
Any thoughts?