Skip to content

Commit 797fc07

Browse files
committed
Rpm based comp power level f421
1 parent 562efaf commit 797fc07

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

Mcu/f051/Inc/comparator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//#define COMP_PA4 0b1000101
1515
//#define COMP_PA5 0b1010101
1616

17-
//// High speed comparator
17+
// High speed comparator
1818
#define COMP_PA0 0b1100001
1919
#define COMP_PA4 0b1000001
2020
#define COMP_PA5 0b1010001

Mcu/f051/Src/comparator.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
COMP_TypeDef* active_COMP = COMP1;
1313

1414
uint8_t getCompOutputLevel() { return LL_COMP_ReadOutputLevel(active_COMP); }
15-
uint8_t medium_speed_set;
1615

1716
void maskPhaseInterrupts()
1817
{
@@ -36,12 +35,9 @@ void changeCompInput()
3635
}
3736
if((average_interval < 400)){
3837
COMP->CSR = COMP->CSR & ~(1<<2);
39-
40-
medium_speed_set = 0;
4138
}
4239
if((average_interval > 600)){
4340
COMP->CSR = COMP->CSR | 1<<2;
44-
medium_speed_set = 1;
4541
}
4642
if (rising) {
4743
EXTI->RTSR = 0x0;

Mcu/f421/Src/comparator.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
#include "comparator.h"
9-
109
#include "targets.h"
10+
#include "common.h"
1111

1212
uint8_t getCompOutputLevel() { return CMP->ctrlsts_bit.cmpvalue; }
1313

@@ -39,6 +39,14 @@ void changeCompInput()
3939
// EXINT->polcfg1 |= (uint32_t)EXTI_LINE;
4040
// EXINT->polcfg2 = 0;
4141
// }
42-
EXINT->polcfg1 = !rising << 21;
42+
if((average_interval < 150)){
43+
//set comp to high speed mode
44+
CMP->ctrlsts = CMP->ctrlsts & ~(1<<2);
45+
}
46+
if((average_interval > 250)){
47+
//set comp to medium speed mode
48+
CMP->ctrlsts = CMP->ctrlsts | 1<<2;
49+
}
50+
EXINT->polcfg1 = !rising << 21;
4351
EXINT->polcfg2 = rising << 21;
4452
}

0 commit comments

Comments
 (0)