PWM doesn’t like its counter or comparator being changed when it is running. The following sequence of separate steps work well for me.
You usually want to use cmp0 to set the periodicity, since it’s at the bottom (least-significant or most repetitious) end of the chain, and use cmp1 to work the duty cycle. You can simultaneously use cmp2 and cmp3 as well, each for different duty cycles if you wish. Of course, you must both enable and select the IOFs of GPIO2 and GPIO3 in that case, as you do above for GPIO1.
This should give you an external monitor signal on GPIO1 (the 48-QFN pin 26) for the internal clock … divided by 1000x. It nicely resolves MHz to KHz for an inexpensive scope.
Hello @pds good to hear from you . How are you? Hope this finds you well.
Here is the thing I am working on.
I try to set the tlclk/core clk to operate at 200 Mhz. After calculating the values for VCO, here is what I find & write. The red lines are your picture while ago for reset values. Green text are my settings/configurations.
(gdb) x /x 0x10008008
0x10008008: 0x80030981
(gdb)
The MSbit is set confirmed the pll is ready and running.
with above clock settings, want to confirm if the clock is really running at 200MHz. Hence configured pwm0 and scoped it.
// pmpcmp0 value to 999
/* set compare value to adjust duty cycle on pwmx_0 */
let pwmcmp0: *mut u32 = PWM_INSTANCE0_BASE_ADDR.byte_add(0x20);
write_volatile(pwmcmp0, 999); // only lower 16 bits writable
To answer to your comment on PWM dont like changing values after enabled. In code I dont do that. Its all configured, then enabled as below. Its embedded rust code.
let cfg_ptr = PWM_INSTANCE0_BASE_ADDR;
write_volatile(cfg_ptr, read_volatile(cfg_ptr) | ( 0x1 << 12 as u32));
Once your response confirmed nothing wrong on my code in pwm, digged into find out that I was probing the wrong pin on board (silk number 9 instead of 8).