How can I directly write a register value in my code?
For example the PWM_CMR_CPOL (0x1u << 9) change the register value 0 to 1.
// This doesn't work
#define PWM_CMR_CPOL 1;
How can I directly write a register value in my code?
For example the PWM_CMR_CPOL (0x1u << 9) change the register value 0 to 1.
// This doesn't work
#define PWM_CMR_CPOL 1;
vorkiej:
How can I directly write a register value in my code?For example the PWM_CMR_CPOL (0x1u << 9) change the register value 0 to 1.
// This doesn't work
#define PWM_CMR_CPOL 1;
That won't work. #define works like a placeholder everywhere the compilers find the term PWM_CMR_CPOL he would replace it with a 1.
Something like this should set the register Value to a 1
PWM->PWM_CMR = PWM_CMR_CPOL;
Thanks Markus_L811, that really helped me!
// solution of my problem was (don't forget the channel number!):
PWM->PWM_CH_NUM[6].PWM_CMR |= PWM_CMR_CPOL;
PWM->PWM_CH_NUM[6].PWM_CMR |= (1 << 9); // or this
// simple test for printing the register values:
void test() {
uint32_t registervalues;
registervalues = PWM->PWM_CH_NUM[6].PWM_CMR;
Serial.println(registervalues,BIN);
delay(1000);
}
// look in the header files for register names, in my case: component_pwm.h and instance_pwm.h
Good, but sorry really missed the channelname.