Skip to content

Commit

Permalink
Rpm based comp power level f421
Browse files Browse the repository at this point in the history
  • Loading branch information
AlkaMotors committed Jan 20, 2025
1 parent b35cbd1 commit c0c6d82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Mcu/f051/Inc/comparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//#define COMP_PA4 0b1000101
//#define COMP_PA5 0b1010101

//// High speed comparator
// High speed comparator
#define COMP_PA0 0b1100001
#define COMP_PA4 0b1000001
#define COMP_PA5 0b1010001
Expand Down
4 changes: 0 additions & 4 deletions Mcu/f051/Src/comparator.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
COMP_TypeDef* active_COMP = COMP1;

uint8_t getCompOutputLevel() { return LL_COMP_ReadOutputLevel(active_COMP); }
uint8_t medium_speed_set;

void maskPhaseInterrupts()
{
Expand All @@ -36,12 +35,9 @@ void changeCompInput()
}
if((average_interval < 400)){
COMP->CSR = COMP->CSR & ~(1<<2);

medium_speed_set = 0;
}
if((average_interval > 600)){
COMP->CSR = COMP->CSR | 1<<2;
medium_speed_set = 1;
}
if (rising) {
EXTI->RTSR = 0x0;
Expand Down
8 changes: 7 additions & 1 deletion Mcu/f421/Src/comparator.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

#include "comparator.h"

#include "targets.h"
#include "common.h"

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

Expand Down Expand Up @@ -39,6 +39,12 @@ void changeCompInput()
// EXINT->polcfg1 |= (uint32_t)EXTI_LINE;
// EXINT->polcfg2 = 0;
// }
if((average_interval < 150)){
CMP->ctrlsts = CMP->ctrlsts & ~(1<<2);
}
if((average_interval > 250)){
CMP->ctrlsts = CMP->ctrlsts | 1<<2;
}
EXINT->polcfg1 = !rising << 21;
EXINT->polcfg2 = rising << 21;
}

0 comments on commit c0c6d82

Please sign in to comment.