try to fix 1V-start problem, refactor debugging
This commit is contained in:
parent
f4194c29de
commit
d78cb36712
21
src/debug.cpp
Normal file
21
src/debug.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
Debug::Debug() {
|
||||||
|
P1DIR |= BIT0 | BIT1 | BIT2 | BIT3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Debug::write(uint16_t v) {
|
||||||
|
P1OUT |= BIT1;
|
||||||
|
for (uint8_t i = 0; i < 16; i++) {
|
||||||
|
P1OUT |= BIT3;
|
||||||
|
uint16_t x = v >> i;
|
||||||
|
if ((x & 1) == 1) {
|
||||||
|
P1OUT |= BIT2;
|
||||||
|
} else {
|
||||||
|
P1OUT &= ~BIT2;
|
||||||
|
}
|
||||||
|
P1OUT &= ~BIT3;
|
||||||
|
}
|
||||||
|
P1OUT &= ~BIT1;
|
||||||
|
}
|
8
src/debug.h
Normal file
8
src/debug.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
class Debug {
|
||||||
|
public:
|
||||||
|
Debug();
|
||||||
|
void write(uint16_t v);
|
||||||
|
}
|
@ -1,12 +0,0 @@
|
|||||||
// P1OUT |= BIT1;
|
|
||||||
// for (uint8_t i = 0; i < 16; i++) {
|
|
||||||
// P1OUT |= BIT3;
|
|
||||||
// uint16_t x = newPwm >> i;
|
|
||||||
// if ((x & 1) == 1) {
|
|
||||||
// P1OUT |= BIT2;
|
|
||||||
// } else {
|
|
||||||
// P1OUT &= ~BIT2;
|
|
||||||
// }
|
|
||||||
// P1OUT &= ~BIT3;
|
|
||||||
// }
|
|
||||||
// P1OUT &= ~BIT1;
|
|
@ -60,11 +60,14 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SwitchPort2 switch1 = SwitchPort2(BIT0);
|
SwitchPort2 switch1;
|
||||||
SwitchPort2 switch2 = SwitchPort2(BIT1);
|
SwitchPort2 switch2;
|
||||||
SwitchPort2 switch3 = SwitchPort2(BIT2);
|
SwitchPort2 switch3;
|
||||||
|
|
||||||
void hmiInit() {
|
void hmiInit() {
|
||||||
|
switch1 = SwitchPort2(BIT0);
|
||||||
|
switch2 = SwitchPort2(BIT1);
|
||||||
|
switch3 = SwitchPort2(BIT2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hmiExec() {
|
void hmiExec() {
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <intrinsics.h>
|
#include <intrinsics.h>
|
||||||
//#include <isr_compat.h>
|
|
||||||
#include <msp430g2553.h>
|
#include <msp430g2553.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -25,8 +24,6 @@ void init() {
|
|||||||
BCSCTL1 = XT2OFF | RSEL0 | RSEL1 | RSEL2 | RSEL3;
|
BCSCTL1 = XT2OFF | RSEL0 | RSEL1 | RSEL2 | RSEL3;
|
||||||
BCSCTL2 = 0;
|
BCSCTL2 = 0;
|
||||||
BCSCTL3 = 0;
|
BCSCTL3 = 0;
|
||||||
|
|
||||||
P1DIR |= BIT0 | BIT1 | BIT2 | BIT3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
const uint32_t ADC_TIME_OUT = 100000;
|
const uint32_t ADC_TIME_OUT = 100000;
|
||||||
const uint16_t ADC_MAX = 511;
|
const uint16_t ADC_MAX = 511;
|
||||||
|
|
||||||
|
const uint16_t PWM_MIN = 0;
|
||||||
|
const uint16_t PWM_MAX = 511;
|
||||||
|
|
||||||
const uint8_t DAMPING = 5;
|
const uint8_t DAMPING = 5;
|
||||||
|
|
||||||
const float Ctrl_P = 10.0;
|
const float Ctrl_P = 10.0;
|
||||||
@ -15,7 +18,6 @@ const float U_ref = 3.3;
|
|||||||
const float R_top = 100000.0;
|
const float R_top = 100000.0;
|
||||||
const float R_bottom = 6200.0;
|
const float R_bottom = 6200.0;
|
||||||
|
|
||||||
const float U_des = 5.0;
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* PARAMS_H_ */
|
#endif /* PARAMS_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user