try to fix 1V-start problem, refactor debugging

This commit is contained in:
Wolfgang Hottgenroth 2015-02-23 09:56:15 +01:00
parent f4194c29de
commit d78cb36712
7 changed files with 38 additions and 22 deletions

21
src/debug.cpp Normal file
View 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
View File

@ -0,0 +1,8 @@
#include <stdint.h>
class Debug {
public:
Debug();
void write(uint16_t v);
}

View File

@ -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;

View File

@ -60,11 +60,14 @@ private:
};
SwitchPort2 switch1 = SwitchPort2(BIT0);
SwitchPort2 switch2 = SwitchPort2(BIT1);
SwitchPort2 switch3 = SwitchPort2(BIT2);
SwitchPort2 switch1;
SwitchPort2 switch2;
SwitchPort2 switch3;
void hmiInit() {
switch1 = SwitchPort2(BIT0);
switch2 = SwitchPort2(BIT1);
switch3 = SwitchPort2(BIT2);
}
void hmiExec() {

View File

@ -6,7 +6,6 @@
*/
#include <intrinsics.h>
//#include <isr_compat.h>
#include <msp430g2553.h>
#include <stdint.h>
@ -25,8 +24,6 @@ void init() {
BCSCTL1 = XT2OFF | RSEL0 | RSEL1 | RSEL2 | RSEL3;
BCSCTL2 = 0;
BCSCTL3 = 0;
P1DIR |= BIT0 | BIT1 | BIT2 | BIT3;
}
int main() {

View File

@ -5,6 +5,9 @@
const uint32_t ADC_TIME_OUT = 100000;
const uint16_t ADC_MAX = 511;
const uint16_t PWM_MIN = 0;
const uint16_t PWM_MAX = 511;
const uint8_t DAMPING = 5;
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_bottom = 6200.0;
const float U_des = 5.0;
#endif /* PARAMS_H_ */

View File

@ -3,9 +3,6 @@
const uint16_t PWM_MIN = 0;
const uint16_t PWM_MAX = 511;
const uint16_t CYCLE_DELAY = 1;
void pwmInit();