I'm aiming at using the pwm peripheral in FIFO serializer mode to generate a stepping pulse train for a stepper motor driver, where I have control over the number of steps/pulses generated. My project is a Raspbian userland process for the Pi 3B+/4B.
Generally it works, but I'm having trouble with bus errors (indicated by the BERR bit in the STA register), and as far as I can diagnose, this sometimes seems to cause my writes to pwm registers to be ignored/skipped (mainly the CTL register).
I have been unable to find any information on the BERR condition except for the sentence in the peripheral datasheet:
This, however, is not really helpful regarding how to avoid bus errors, or what mitigation to take if they occur. I see other pwm code/examples sprinkle small delays all over the code between register writes - is this related to BERR? Surely there must be an official method to this other than arbitrary delays here and there?BERR sets to high when an error has occurred while writing to registers via APB. This may happen if the bus tries to write successively to same set of registers faster than the synchroniser block can cope with. Multiple switching may occur and contaminate the data during synchronisation. Software should clear this bit by writing 1. Writing 0 to this bit has no effect.