This commit is contained in:
Wolfgang Hottgenroth 2016-09-22 11:13:46 +02:00
commit bde508d6c3
7 changed files with 87 additions and 19 deletions

View File

@ -28,16 +28,19 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/hottislib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/hottislibformsp430}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/hottislib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/hottislibformsp430}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/src}&quot;"/>
</option>
<option id="dk.xpg.msp430eclipse.compiler.option.language.standard.1069227926" superClass="dk.xpg.msp430eclipse.compiler.option.language.standard" useByScannerDiscovery="false" value="dk.xpg.msp430eclipse.compiler.option.language.standard.gnu99" valueType="enumerated"/>
<option id="dk.xpg.msp430eclipse.compiler.option.language.standard.1069227926" name="Standard" superClass="dk.xpg.msp430eclipse.compiler.option.language.standard" useByScannerDiscovery="false" value="dk.xpg.msp430eclipse.compiler.option.language.standard.gnu99" valueType="enumerated"/>
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.2144495992" name="C Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input"/>
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc.194364093" name="C++ Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc"/>
</tool>
<tool id="dk.xpg.msp430eclipse.tool.assembler.gcc.1721201165" name="MSP430 Assembler" superClass="dk.xpg.msp430eclipse.tool.assembler.gcc">
<option id="dk.xpg.msp430eclipse.assembler.option.general.include.1531893167" name="Include Paths (-I)" superClass="dk.xpg.msp430eclipse.assembler.option.general.include" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/hottislib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/hottislibformsp430}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/hottislib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/hottislibformsp430}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/src}&quot;"/>
</option>
<inputType id="dk.xpg.msp430eclipse.tool.assembler.input.975463794" name="Assembler Files" superClass="dk.xpg.msp430eclipse.tool.assembler.input"/>
</tool>
@ -84,6 +87,9 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/hottislib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/hottislibformsp430}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/hottislib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/hottislibformsp430}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/src}&quot;"/>
</option>
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.2045842702" name="C Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input"/>
<inputType id="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc.1959192171" name="C++ Source File" superClass="dk.xpg.msp430eclipse.tool.compiler.gcc.input.cc"/>
@ -93,6 +99,9 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/hottislib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/hottislibformsp430}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Inverter0/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/hottislib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/hottislibformsp430}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/inverter0/src}&quot;"/>
</option>
<inputType id="dk.xpg.msp430eclipse.tool.assembler.input.1253938813" name="Assembler Files" superClass="dk.xpg.msp430eclipse.tool.assembler.input"/>
</tool>

View File

@ -1,2 +1,7 @@
eclipse.preferences.version=1
msp430/DeviceSerialNumber=
msp430/MSP430TARGETMCU=msp430g2553
msp430/MSPDebugConnection=USB
msp430/MSPDebugDriver=rf2500
msp430/MSPDebugProtocol=SBW
msp430/MSPDebugTTYDevice=

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -13,30 +13,82 @@
#include "inverter.h"
#define NUM_OF_SINE_VALUES 10
float sineValues[NUM_OF_SINE_VALUES] = {
0.3090,
0.5878,
0.8090,
0.9511,
1.0000,
0.9511,
0.8090,
0.5878,
0.3090,
0.0000,
};
volatile uint16_t pulseWidths[NUM_OF_SINE_VALUES * 2] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
volatile uint8_t pulseWidthIdx = 0;
volatile uint8_t activeOffset = 0;
ISR(TIMER1_A0, TA1_ISR_Ovrfl) {
if (pulseWidthIdx == 0) {
P1OUT ^= BIT1;
}
uint16_t pw = pulseWidths[pulseWidthIdx + activeOffset];
if (pw != 0) {
TA1CCR1 = pw;
P2OUT |= BIT1;
}
pulseWidthIdx++;
if (pulseWidthIdx >= NUM_OF_SINE_VALUES) {
pulseWidthIdx = 0;
}
}
//ISR(TIMER1_A1, TA1_ISR_Comp) {
//
//}
ISR(TIMER1_A1, TA1_ISR_Comp) {
if (TA1IV & TA1IV_TACCR1) {
P2OUT &= ~BIT1;
}
}
void inverterInit() {
P2OUT &= ~BIT1;
P2DIR |= BIT1;
P2SEL |= BIT1;
P1OUT &= ~BIT1;
P1DIR |= BIT1;
P2OUT &= ~BIT0;
P2DIR |= BIT0;
P2SEL |= BIT0;
P2OUT &= ~BIT1;
P2DIR |= BIT1;
P2OUT &= ~BIT0;
P2DIR |= BIT0;
P2SEL |= BIT0;
TA1CTL = MC_1 | ID_3 | TASSEL_2 | TACLR;
TA1CCTL0 = CCIE | OUTMOD_4;
TA1CCTL1 = OUTMOD_7;
TA1CCR0 = 200;
TA1CCR1 = 62;
TA1CTL = MC_1 | ID_1 | TASSEL_2 | TACLR;
TA1CCTL0 = CCIE | OUTMOD_4;
TA1CCTL1 = CCIE;
TA1CCR0 = 0;
TA1CCR1 = 0;
}
void inverterSetFrequency(uint16_t f) {
float ff = (float)f;
float slotLength = 100.0 / (ff * 9.8e-6 * 20);
uint8_t currentOffset = (activeOffset == 0) ? NUM_OF_SINE_VALUES : 0;
for (uint8_t i = 0; i < NUM_OF_SINE_VALUES; i++) {
pulseWidths[i + currentOffset] = (uint16_t)(slotLength * sineValues[i]);
}
__disable_interrupt();
activeOffset = currentOffset;
TA1CCR0 = (uint16_t)slotLength;
pulseWidthIdx = 0;
__enable_interrupt();
}

View File

@ -11,6 +11,6 @@
#include <stdint.h>
void inverterInit();
void inverterSetFrequency(uint8_t f);
void inverterSetFrequency(uint16_t f);
#endif /* INVERTER_H_ */

View File

@ -30,6 +30,8 @@ int main() {
__enable_interrupt();
inverterSetFrequency(100);
while (1) {
}
}