brainmsp430
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
brainmsp430 [2016/01/16 16:23] – admin | brainmsp430 [2016/01/30 15:59] – admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | ||
#include < | #include < | ||
Line 10: | Line 9: | ||
{1, | {1, | ||
{1, | {1, | ||
- | {1,12,14,11, | + | {1,15,14,13,12,14,11,10,9,8,11,10,9,8,9,8,9,10,8,10,9, |
{1, | {1, | ||
{1, | {1, | ||
Line 18: | Line 17: | ||
}; | }; | ||
const unsigned int brainDuration[8][63] = { | const unsigned int brainDuration[8][63] = { | ||
- | {1, | + | {0, |
- | {2, | + | {1, |
+ | {2, | ||
{3, | {3, | ||
{4, | {4, | ||
{5, | {5, | ||
{6, | {6, | ||
- | {7,5,15,10,5,10,8,10,10, | + | {7, |
- | {8, | + | |
}; | }; | ||
- | const unsigned int ArrayLength[8] = {31,28,39, | + | const unsigned int ArrayLength[8] = {31,28,34, |
volatile unsigned int on = 0; | volatile unsigned int on = 0; | ||
// Declaration of functions | // Declaration of functions | ||
Line 43: | Line 42: | ||
IFG1 &= ~WDTIFG; | IFG1 &= ~WDTIFG; | ||
IE1 |= WDTIE; // Enable WDT interrupt | IE1 |= WDTIE; // Enable WDT interrupt | ||
- | P1DIR | + | P1SEL = 0x00; // Set all Pins to GPIO Pins, no clock sources, nothing |
+ | P1SEL2 = 0x00; // Set all Pins to GPIO Pins, no clock sources, nothing | ||
+ | P2SEL = 0x00; | ||
+ | P2SEL2 = 0x00; | ||
+ | P3SEL = 0x00; | ||
+ | P3SEL2 = 0x00; | ||
+ | | ||
P1REN = 0x30; // Set P1.4 - P1.5 pull down resistor | P1REN = 0x30; // Set P1.4 - P1.5 pull down resistor | ||
- | | + | |
- | P2DIR | + | P2DIR = 0xF8; // Set P2.0 - P2.2 as Intput |
P2REN = 0x07; // Set P2.0 - P2.2 pull down resistor | P2REN = 0x07; // Set P2.0 - P2.2 pull down resistor | ||
- | P2OUT | + | P2OUT = 0x00; // Set P2.0 - P2.7 to 0 |
+ | P3DIR = 0xFF; | ||
+ | P3OUT = 0x00; | ||
// Timer_A | // Timer_A | ||
TA0CCR0 = 1250; // Count limit for 400Hz at !MHz (1000000 / 400 / 2) | TA0CCR0 = 1250; // Count limit for 400Hz at !MHz (1000000 / 400 / 2) | ||
Line 84: | Line 90: | ||
} | } | ||
else{ | else{ | ||
- | P1OUT &= 0x00; | + | P1DIR = 0xFF; // Set P1.0 - P1.7 as output |
- | P1OUT &= 0x00; | + | P2DIR = 0xFF; // Set P2.0 - P2.7 as output |
- | _BIS_SR(LPM3_bits); | + | P1OUT = 0x00; |
+ | P2OUT = 0x00; | ||
+ | __dint(); | ||
+ | _BIS_SR(LPM4_bits); | ||
} | } | ||
} | } | ||
Line 132: | Line 141: | ||
unsigned long millis(){ | unsigned long millis(){ | ||
return doublemillis >> 1; // Double Millisecondy divided by 2 | return doublemillis >> 1; // Double Millisecondy divided by 2 | ||
- | } | ||
- | |||
- | // -------------------------- Interrupts ------------------------------------------ | ||
- | #pragma vector=WDT_VECTOR | ||
- | __interrupt void WDT(void){ | ||
- | doublemillis++; | ||
- | } | ||
- | |||
- | #pragma vector=TIMER0_A0_VECTOR | ||
- | __interrupt void Timer0_A0 (void) { | ||
- | P1OUT ^= 0x04; // Toggle output P1.2 | ||
} | } | ||
Line 150: | Line 148: | ||
} | } | ||
- | </ |
brainmsp430.txt · Last modified: 2019/08/06 15:11 by admin