Skip to content

Commit fbb0d8f

Browse files
committed
Unstable debug changes
- Unstable version. - Enabled more debug pins to investigate malfunctioning. - Played around with comparator filter settings.
1 parent 428b158 commit fbb0d8f

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
lines changed

.settings/language.settings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
55
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
66
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
7-
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="([^/\\\\]*)((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
8-
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-221202164080" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
7+
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
8+
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1606774695304" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
99
<language-scope id="org.eclipse.cdt.core.gcc"/>
1010
<language-scope id="org.eclipse.cdt.core.g++"/>
1111
</provider>

Mcu/a153/Src/comparator.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@ LPCMP_Type *MAIN_COMP = CMP0;
1414
//int filt_cnt = 5; //Set to 5 so we sample at 60kHz which causes it to precisely trigger only once every rising/falling BEMF
1515
//int sample_en = 0;
1616

17-
int filt_sample_per = 4; //4 = 3MHz
18-
int filt_cnt = 5; //Set a sampling freq of 600kHz, so 5*600kHz = 3MHz total sampling freq
19-
int sample_en = 0;
17+
//int filt_sample_per = 4; //4 = 3MHz
18+
//int filt_cnt = 5; //Set a sampling freq of 600kHz, so 5*600kHz = 3MHz total sampling freq
19+
//int sample_en = 0;
20+
21+
//int filt_sample_per = 2;
22+
//int filt_cnt = 7;
23+
//int sample_en = 0;
24+
25+
int filt_sample_per = 0;
26+
int filt_cnt = 1;
27+
int sample_en = 1;
28+
int cmp_hpmd = 0;
2029

2130
//int filt_sample_per = 0;
2231
//int filt_cnt = 0;
@@ -51,7 +60,7 @@ void initComp0(void)
5160
modifyReg32(&CMP0->CCR2, LPCMP_CCR2_PSEL_MASK, LPCMP_CCR2_PSEL(COMMON_COMP0_INP));
5261

5362
//Enable high speed comparator mode
54-
// modifyReg32(&CMP0->CCR2, LPCMP_CCR2_CMP_HPMD_MASK, LPCMP_CCR2_CMP_HPMD(1));
63+
modifyReg32(&CMP0->CCR2, LPCMP_CCR2_CMP_HPMD_MASK, LPCMP_CCR2_CMP_HPMD(cmp_hpmd));
5564

5665
//Set filter sample period to x clock cycles
5766
modifyReg32(&CMP0->CCR1, LPCMP_CCR1_FILT_PER_MASK, LPCMP_CCR1_FILT_PER(filt_sample_per));
@@ -95,7 +104,7 @@ void initComp1(void)
95104
modifyReg32(&CMP1->CCR2, LPCMP_CCR2_PSEL_MASK, LPCMP_CCR2_PSEL(COMMON_COMP1_INP));
96105

97106
//Enable high speed comparator mode
98-
// modifyReg32(&CMP1->CCR2, LPCMP_CCR2_CMP_HPMD_MASK, LPCMP_CCR2_CMP_HPMD(1));
107+
modifyReg32(&CMP1->CCR2, LPCMP_CCR2_CMP_HPMD_MASK, LPCMP_CCR2_CMP_HPMD(cmp_hpmd));
99108

100109
//Set filter sample period to x clock cycles
101110
modifyReg32(&CMP1->CCR1, LPCMP_CCR1_FILT_PER_MASK, LPCMP_CCR1_FILT_PER(filt_sample_per));

Mcu/a153/Src/mcxa153_it.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ char input_ready = 0;
3232
void CMP0_IRQHandler(void)
3333
{
3434
//TODO remove this
35-
GPIO3->PTOR = (1 << 27); //ENC_A
35+
// GPIO3->PTOR = (1 << 27); //ENC_A
3636

3737
//Call function from main.c
3838
interruptRoutine();
@@ -47,7 +47,7 @@ void CMP0_IRQHandler(void)
4747
void CMP1_IRQHandler(void)
4848
{
4949
//TODO remove this
50-
GPIO3->PTOR = (1 << 27); //ENC_A
50+
// GPIO3->PTOR = (1 << 27); //ENC_A
5151

5252
//Call function from main.c
5353
interruptRoutine();

Mcu/a153/Src/peripherals.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ void initGPIO(void)
193193
PORT_PCR_MUX(0) | PORT_PCR_PE(1) | PORT_PCR_PS(0));
194194
modifyReg32(&GPIO3->PDDR, 0, (1 << 28));
195195
GPIO3->PCOR = (1 << 28);
196+
197+
modifyReg32(&PORT2->PCR[12], //SPI_SCK
198+
PORT_PCR_MUX_MASK | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK,
199+
PORT_PCR_MUX(0) | PORT_PCR_PE(1) | PORT_PCR_PS(0));
200+
modifyReg32(&GPIO2->PDDR, 0, (1 << 12));
201+
GPIO2->PCOR = (1 << 12);
196202
}
197203

198204
void enableCorePeripherals()

Src/main.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,9 @@ void commutate()
823823
if (!prop_brake_active) {
824824
comStep(step);
825825
}
826-
__enable_irq();
827826
changeCompInput();
827+
__enable_irq();
828+
// changeCompInput(); //TODO change this back
828829
#ifndef NO_POLLING_START
829830
if (average_interval > 2500) {
830831
old_routine = 1;
@@ -853,6 +854,9 @@ void PeriodElapsedCallback()
853854
{
854855
DISABLE_COM_TIMER_INT(); // disable interrupt
855856

857+
//TODO Remove this
858+
GPIO2->PTOR = (1 << 12); //SPI_SCK
859+
856860
commutate();
857861
// commutation_interval = (3 * commutation_interval + thiszctime) >> 2;
858862
commutation_interval = ((commutation_interval)+((lastzctime + thiszctime) >> 1)) >> 1;
@@ -879,6 +883,9 @@ void PeriodElapsedCallback()
879883
*/
880884
void interruptRoutine()
881885
{
886+
//TODO remove this
887+
GPIO3->PTOR = (1 << 27); //ENC_A
888+
882889
if (average_interval > 125) {
883890
if ((INTERVAL_TIMER_COUNT < 125) && (duty_cycle < 600) && (zero_crosses < 500)) { // should be impossible, desync?exit anyway
884891
return;
@@ -1673,11 +1680,11 @@ int main(void)
16731680
eepromBuffer.variable_pwm = 1;
16741681

16751682
eepromBuffer.stuck_rotor_protection = 0;//1; //Causes input = 0; when this is 1
1676-
eepromBuffer.advance_level = 2;
1683+
eepromBuffer.advance_level = 2;//2;
16771684
// eepromBuffer.auto_advance = 1;
1678-
eepromBuffer.pwm_frequency = 24;
1685+
eepromBuffer.pwm_frequency = 24;//24;
16791686
eepromBuffer.startup_power = 100;
1680-
eepromBuffer.motor_kv = 55;
1687+
eepromBuffer.motor_kv = 255;//55;
16811688
eepromBuffer.motor_poles = 14;//14;
16821689
eepromBuffer.beep_volume = 5;
16831690
eepromBuffer.servo.low_threshold = 128;

0 commit comments

Comments
 (0)