0

I have Arduino Due, and I want it to output clock at 3.072MHz (which is a clock rate used for I2S) How do I go about this?

I tried the following code, but it doesn't give the exact rate, and I suppose additional tinkering is required:

void setup() {
int32_t freq = 3072000;
int32_t mask_PWM_pin = digitalPinToBitMask(6);
REG_PMC_PCER1 = 1<<4;
REG_PIOC_PDR |= mask_PWM_pin;
REG_PIOC_ABSR |= mask_PWM_pin;
REG_PWM_CLK = 0;
REG_PWM_CMR7 = 0<<9;
REG_PWM_CPRD7 = 84000000/freq;
REG_PWM_CDTY7 = 42000000/freq;
REG_PWM_ENA = 1<<7;
}

void loop() {
}

Thanks!

Your Answer

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

Browse other questions tagged or ask your own question.