Jump to content


  • Content Count

  • Joined

  • Last visited

  1. ozymandias

    Launchpad + AS1106 + 8x8 LED Matrix = fun!

    i don't have much mounting advice except: -cut a big enough hole. -use enough hot glue. whaddya mean P2? i though this was a G2211?
  2. ozymandias

    Launchpad + AS1106 + 8x8 LED Matrix = fun!

    super sweet! is there a perf. board in a case version coming along?
  3. ozymandias

    Simulating programs

    I was wondering about testing programs with external input in mspdebug's simulation mode. For instance, foo is done in a Port1 ISR or a USI slave ISR. I can see writing to the P1 register to set off the P1 ISR, but in the case of USI would you have to manualy write to the USI in, cycle however many clock steps matches the time elapsed before the next event and write to the register again? Does anybody know of a slicker way to do simulation of a program with real world timing and signals in mind?
  4. ozymandias

    Makerbot redone with '430s

    Indeed that is the plan, Rick. Once the structure of the data is nailed down, i'll start on using lex-yacc/flex-bison to make a compiler that will take in g-code and spit out a ascii file of characters to transmit.
  5. ozymandias

    Makerbot redone with '430s

    I've had a Makerbot Cupcake CNC for a while now and have been wanting to convert it from the current arduino-bobino-fee-fi-sanguino controller to lightweight and modular MSP430 subsystems that would be useful in other control and robotics projects. currently i have beta software that takes in UART data from a computer (i'm using GTKterm in linux) to the launchpad, where a G2231 controls chip select bits and resends the byte to (currently 3) other 2231's. What i'm planning to do soon is modify the Makerbot to "close the loop" as far as control. Currently, you only theorectically know what state (where each bit is) by knowing what you've told it to do already; the "open loop" control (usually bad). I've put up beta code in the code vault and i should :!: have proof of concept up and running by the end of the week.
  6. Project: control 3 MSP430G2231's using a single G2231 as a bridge/converter/demultiplexer that recieves data through the USB the bridge takes bytes and puts alternately sends them to recievers 1-3. the recievers' P1.0 and P1.6 go to stepper motor controllers to step on rising edge and control direction, respectively. "bridge" part: -recieves bytes from 2400 8N1 input to P1.1 (requires launchpad 'RXD' jumper to be removed and the pin on the FTDI side connected to P1.1) -after reception, transmits each byte out of P1.6 as MOSI and P1.5 as SCLK. -cycles through bringing one of three output pins low as a chip select #include #include // Conditions for 2400 Baud SW UART, ACLK = 32768 #define Bitime_5 0x06 // ~ 0.5 bit length + small adjustment #define Bitime 0x0E // 427us bit length ~ 2341 baud #define RXD 0x02 #define TXD 0x20 #define LED1 0x01 #define LED2 0x40 unsigned char RXTXData; unsigned char BitCnt; unsigned char temp; static void __inline__ delay(register unsigned int n); int main (void){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer CCTL0 = OUT; // TXD Idle as Mark TACTL = TASSEL_1 + MC_2; // ACLK, continuous mode P1SEL = TXD + RXD; // P1DIR = TXD + LED1 + BIT4 + BIT3; P1OUT = LED1 + BIT4 + BIT3; USICTL0 = USIPE7 | USIPE6 | USIPE5 | USIMST | USIOE | USISWRST; // Port, SPI Master USICTL1 = USICKPH | USIIE; USICKCTL = 0xE4;// /128 aclk? temp = 0; while(1){ P1OUT |= LED1 + BIT4 + BIT3; BitCnt = 0x8; // Load Bit counter CCTL0 = SCS + OUTMOD0 + CM1 + CAP + CCIE; // Sync, Neg Edge, Cap _BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interr until char RXed if(temp == 2){ temp = 0; }else{ temp = temp +1; } } } // #pragma vector=TIMERA0_VECTOR interrupt(TIMERA0_VECTOR) Timer_A (void){ CCR0 += Bitime; // Add Offset to CCR0 if( CCTL0 & CAP ){ // Capture mode = start bit edge CCTL0 &= ~ CAP; // Switch from capture to compare mode CCR0 += Bitime_5; }else{ RXTXData = RXTXData >> 1; if (CCTL0 & SCCI) // Get bit waiting in receive latch RXTXData |= 0x80; BitCnt --; // All bits RXed? if ( BitCnt == 0){ USISRL = RXTXData; if(temp == 0){ P1OUT &= ~LED1; P1OUT |= BIT4 + BIT3; }else if(temp == 1){ P1OUT &= ~BIT4; P1OUT |= LED1 + BIT3; }else if(temp == 2){ P1OUT &= ~BIT3; P1OUT |= LED1 + BIT4; } USICNT |= 0x08; USICTL0 &= ~USISWRST; while (!(USIIFG & USICTL1)); USICTL0 |= USISWRST; delay(0); P1OUT |= LED1 + BIT4 + BIT3; CCTL0 &= ~ CCIE; // All bits RXed, disable interrupt _BIC_SR_IRQ(LPM3_bits + GIE); // Clear LPM3 bits from 0(SR) } } } static void __inline__ delay(register unsigned int n) { __asm__ __volatile__ ( "1: \n" " dec %[n] \n" " jne 1b \n" : [n] "+r"(n)); } The reciever recieves the byte from the bridge and in state machine fashion puts the byte in: -a counter for number of steps to take -determines to set or clear a direction bit -sets TACCR0 to control toggle rate #include #include unsigned int bufff; unsigned char count; int main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1OUT = 0x00; // P1.4 set, else reset P1DIR = 0x01 + BIT6; // P1.0 output, else input USICTL0 |= USIPE7 + USIPE5; // Port, SPI slave USICTL1 |= USIIE; // Counter interrupt, flag remains set USICTL0 &= ~USISWRST; // USI released for operation USICNT = 8; // init-load counter bufff = 0; count = 0; TACTL = TASSEL_1 | MC_1; //Set TimerA to use auxiliary clock in UP mode TACCTL0 = CCIE; //Enable the interrupt for TACCR0 match TACCR0 = 2; _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt while(1){ } } // USI interrupt service routine interrupt(USI_VECTOR) universal_serial_interface(void){ if(count == 0){//bufff if(USISRL > 0x7A){ bufff = bufff + 0xFF00; }else{ bufff = bufff + USISRL; } }else if(count == 1){//dir if(USISRL > 0x3F){ P1OUT |= BIT6; }else{ P1OUT &= ~BIT6; } }else if(count == 2){//speed TACCR0 = USISRL; }else{ count = 0; } count = count + 1; if(count == 3){ count = 0; } USICNT = 8; // re-load counter } interrupt(TIMERA0_VECTOR) TIMERA0_ISR(void) { if( bufff > 0){ P1OUT ^= BIT0; bufff = bufff - 1; } } PROBLEMS: -the bridge can't pass data through it too fast. one must wait about ~200ms until the next byte is sent to prevent data loss. (the code isn't optimized and kinda "fatty" in all likelihood). -since the TimerA assignments from USI data occur in the USI-ISR (and i haven't found a reliable way to do it otherwise), the data isn't 'pushed' into TimerA until the next byte is recieved. -it would be cool to not have to modify the jumpers on the launchpad to do the UART, but its based on TI code that worked so i went with it.
  7. ozymandias

    G2231 UART echo not quite working

    :shock: :shock: It just works! WTF, thats not supposed to happen. Thank you! IOU a drink sir.
  8. ozymandias

    G2231 UART echo not quite working

    So, I have been trying to make a UART to SPI "bridge", so as a first step I'm making a UART echo program to verify that the UART is recieving data correctly. I started with a TI example program which had both TX and RX in one timerA ISR. The program didn't work as it was supposed to, so i kept the TX in the timerA0 ISR and put RX in the timerA1 ISR. This sort-of worked, as it transmitted data back, but the data is invariably 0xFF (though it transmits 0x00 the first time after the chip is programmed). Here is the code, if somebody sees any glaring errors: #include #include #define RXD BIT2 #define TXD BIT1 #define LED2 BIT6 #define LED1 BIT0 #define Bitime_5 0x06 #define Bitime 0x0E unsigned int RXTXData; unsigned char BitCnt; void TX_Byte (void); void RX_Ready (void); int main (void){ WDTCTL = WDTPW + WDTHOLD; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; CCTL0 = OUT; TACTL = TASSEL_1 + MC_2; P1SEL = TXD + RXD; P1DIR = TXD + LED1 + LED2; CCTL1 = SCS + OUTMOD0 + CM1 + CAP + CCIE; while(1){ RX_Ready(); _BIS_SR(CPUOFF + GIE); TX_Byte(); } } void TX_Byte (void){ BitCnt = 0xA; while (CCR0 != TAR){ CCR0 = TAR; } CCR0 += Bitime; RXTXData |= 0x100; RXTXData = RXTXData << 1; CCTL0 = CCIS0 + OUTMOD0 + CCIE; while ( CCTL0 & CCIE ){} } void RX_Ready (void){ BitCnt = 0x8; CCTL1 = SCS + OUTMOD0 + CM1 + CAP + CCIE; } interrupt(TIMERA0_VECTOR) Timer_A0(void){ CCR0 += Bitime; if (CCTL0 & CCIS0){ if ( BitCnt == 0){ CCTL0 &= ~ CCIE; }else{ CCTL0 |= OUTMOD2; if (RXTXData & 0x01){ CCTL0 &= ~ OUTMOD2; } RXTXData = RXTXData >> 1; BitCnt --; } } } interrupt(TIMERA1_VECTOR) Timer_A1(void){ CCR1 += Bitime; if(CCTL1 & CAP){ CCTL1 &= ~ CAP; CCR1 += Bitime_5; }else{ RXTXData = RXTXData >> 1; if (CCTL1 & SCCI){ RXTXData |= 0x80; } BitCnt --; if ( BitCnt == 0){ P1OUT ^= LED2; CCTL1 &= ~ CCIE; _BIC_SR_IRQ(LPM3_bits); } } } Sorry there aren't any proper comments. EDIT: forgot to mention that this is a MSP430G2231 on the launchpad with a 32KHz crystal, and the UART is set for 2400 8N1. LED2 does indeed toggle when data is sent to the chip and if one assigns a value to RXTXData, it does transmit that byte successfully.
  9. ozymandias

    msp430-gcc mmcu flags

    Cool cool. Thanks guys. It looks like I have an old version of 430gcc, but it works at the moment for my 2231's, so I'll just wait until a newer version pops up on the YUM repos.
  10. ozymandias

    msp430-gcc mmcu flags

    once upon a time i managed to bumble my way into getting programs to correctly compile for the G2231s that i have lying around using the flag -mmcu=msp430x2012 . my first question is, does anybody know why this works, as it seems it shouldn't and second, what would be the proper flag for the FRaunchpad? mspdebug seems to talk to it fine, but i'm not sure how to compile for it just yet. PS. does anybody have the code to the demo program that comes aboard the FRaunchpad? it would be a great reference.
  11. would i be right in saying that the launchpad ONLY has 2 line SBW capability? whats a good option to program MSPs with only 4-wire JTAG?
  12. ozymandias

    another launchpad programming question

    the links in the E2E link above are dead. I have the links, but i'm too new a user to post them. Thanks for the help, i'll look through them.
  13. can most any msp430 uC be programmed by the launchpad or just the "value line" little tiny ones?
  14. ozymandias


    hi all. long time lurker, first time user. I picked up a launchpad a while ago and have enjoyed using the msp430 MUCH more than the Freescale HCS12 that i had to use in my microcontrollers course. It saved my bacon in a embedded controls class insofar as i didn't have to use the 'suggested' Altera DE0 FPGA and its associated crappy software. I'm currently working on using a few 430s to liberate my makerbot from the arduinos it came with.