cancel
Showing results for 
Search instead for 
Did you mean: 

Switch comparator input

Vertinhol
Associate III

Hello, I made a an esc using an arduino a year ago and I wanted to try it with my stm32L476RG, for some reason my code doesn't seem to work, and I think that I'm doing the switching of the comparator input minus wrong, can you tell me if this is the right way or not please.

#define BEMF_A_Pin 0x00000060
#define BEMF_B_Pin 0x00000040
#define BEMF_C_Pin 0x00000050
OR
#define BEMF_A_Pin COMP_INPUT_MINUS_IO2
#define BEMF_B_Pin COMP_INPUT_MINUS_DAC1_CH1
#define BEMF_C_Pin COMP_INPUT_MINUS_DAC1_CH2
// I tried both
 
#define BEMF_P_MSK 0xFFFFFF8F
 
COMP1->CSR = (COMP1->CSR & BEMF_P_MSK) | BEMF_A_Pin; // Select PC4 as minus input
COMP1->CSR = (COMP1->CSR & BEMF_P_MSK) | BEMF_B_Pin; // Select PA4 as minus input
COMP1->CSR = (COMP1->CSR & BEMF_P_MSK) | BEMF_C_Pin; // Select PA5 as minus input

0 REPLIES 0