Jump to content
43oh

SugarAddict

Members
  • Content Count

    769
  • Joined

  • Last visited

  • Days Won

    26

Reputation Activity

  1. Like
    SugarAddict got a reaction from bluehash in TLC5940... no lights? - Solved (Code & video) (twice)   
    Ok... here's something much nicer... still horribly commented code with some stuff that could be cleaned up or improved...
     


     

    // I know that my commenting sucks ass... I'm not exactly working on a team project here :-P #define SetLow(port, pin) (port &= ~pin) #define SetHigh(port, pin) (port |= pin) #define Pulse(port, pin) do{SetHigh(port, pin);SetLow(port, pin);} while(0) #define DELTA_1MHZ 244 // 244 x 4096Hz = 999.4Hz #define DELTA_8MHZ 1953 // 1953 x 4096Hz = 7.99MHz #define DELTA_12MHZ 2930 // 2930 x 4096Hz = 12.00MHz #define DELTA_16MHZ 3906 // 3906 x 4096Hz = 15.99MHz #define DELTA_18MHZ 4395 // 4395 x 4096Hz = 18.00MHz #define DELTA_20MHZ 4883 // 4883 x 4096Hz = 20.00MHz #define DELTA_24MHZ 5859 // 5859 x 4096Hz = 23.99MHz #include "msp430g2252.h" void Rotate(void); void Bounce(void); void Set_DCO(unsigned int Delta); // Set DCO to selected frequency void SendDotCorrectionData(void); void SendGreyScaleData(void); int dcdata[] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}; int gsdata[] = { 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; char CntrA = 0, CntrB = 0, dcsent = 0, rotator = 0, bounce = 12, bouncedir = 0; int Counter = 0, data = 0, data2 = 0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT // BCSCTL1 = CALBC1_16MHZ; // Set range // DCOCTL = CALDCO_16MHZ; // Set DCO step + modulation Set_DCO(4639); // 19 MHz // 1.6 DCPRG, 1.7 GSCLK // 2.0 VPRG, 2.1/2.2 SIN, 2.3 XLAT. 2.4 SCLK, 2.5 BLANK P1DIR |= (BIT6|BIT7); P2DIR |= (BIT0|BIT1|BIT2|BIT3|BIT4|BIT5); P1OUT &= ~(BIT7); P1OUT |= (BIT6); P2OUT &= ~(BIT1|BIT2|BIT3|BIT4); P2OUT |= (BIT0|BIT5); CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 56; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, Up TACTL |= MC_0; // Stop SendDotCorrectionData(); SendGreyScaleData(); TACTL &= ~MC_0; // Start _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A (void) { Counter++; if(Counter>4095) { TACTL |= MC_0; // Stop Counter = 0; CntrA = 0; CntrB = 0; SetHigh(P2OUT,BIT5); Pulse(P2OUT,BIT3); rotator++; if(rotator>3) { //Rotate(); Bounce(); rotator = 0; } SendGreyScaleData(); TACTL &= ~MC_0; // Start } Pulse(P1OUT, BIT7); } void Rotate(void) { data = gsdata[31]; for(CntrA = 31;CntrA > 0;CntrA--) { gsdata[CntrA] = gsdata[CntrA-1]; } gsdata[0] = data; data = 0; CntrA = 0; } void Bounce(void) { char i = 0; if(bounce == 31) bouncedir = 1; if(bounce == 0) bouncedir = 0; if(bouncedir == 0) // Up { for(i=0;i<32;i++) { gsdata[i] >>= 1; } bounce++; gsdata[bounce] = 0x1000; } else // down { for(i=0;i<32;i++) { gsdata[i] >>= 1; } bounce--; gsdata[bounce] = 0x1000; } } void Set_DCO(unsigned int Delta) // Set DCO to selected frequency { unsigned int Compare, Oldcapture = 0; BCSCTL1 |= DIVA_3; // ACLK = LFXT1CLK/8 TACCTL0 = CM_1 + CCIS_1 + CAP; // CAP, ACLK TACTL = TASSEL_2 + MC_2 + TACLR; // SMCLK, cont-mode, clear while (1) { while (!(CCIFG & TACCTL0)); // Wait until capture occured TACCTL0 &= ~CCIFG; // Capture occured, clear flag Compare = TACCR0; // Get current captured SMCLK Compare = Compare - Oldcapture; // SMCLK difference Oldcapture = TACCR0; // Save current captured SMCLK if (Delta == Compare) break; // If equal, leave "while(1)" else if (Delta < Compare) { DCOCTL--; // DCO is too fast, slow it down if (DCOCTL == 0xFF) // Did DCO roll under? if (BCSCTL1 & 0x0f) BCSCTL1--; // Select lower RSEL } else { DCOCTL++; // DCO is too slow, speed it up if (DCOCTL == 0x00) // Did DCO roll over? if ((BCSCTL1 & 0x0f) != 0x0f) BCSCTL1++; // Sel higher RSEL } } TACCTL0 = 0; // Stop TACCR0 TACTL = 0; // Stop Timer_A BCSCTL1 &= ~DIVA_3; // ACLK = LFXT1CLK } void SendDotCorrectionData(void) { CntrA = 0; CntrB = 0; data = dcdata[CntrA]; while(CntrA<6) { if(CntrB<16) { if(data & 0x8000) { SetHigh(P2OUT,BIT1); SetHigh(P2OUT,BIT2); } else { SetLow(P2OUT,BIT1); SetLow(P2OUT,BIT2); } data <<= 1; CntrB++; Pulse(P2OUT,BIT4); } else { CntrA++; if(CntrA<6) { CntrB = 1; data = dcdata[CntrA]; if(data & 0x8000) { SetHigh(P2OUT,BIT1); SetHigh(P2OUT,BIT2); } else { SetLow(P2OUT,BIT1); SetLow(P2OUT,BIT2); } data <<= 1; Pulse(P2OUT,BIT4); } } } Pulse(P2OUT,BIT3); CntrA = 0; CntrB = 0; dcsent = 1; SetLow(P2OUT,BIT0); } void SendGreyScaleData(void) { CntrA = 0; CntrB = 0; data = gsdata[CntrA]; data2 = gsdata[(CntrA+16)]; while(CntrA<16) { if(CntrB<12) { if(data & 0x1000) SetHigh(P2OUT,BIT1); else SetLow(P2OUT,BIT1); if(data2 & 0x1000) SetHigh(P2OUT,BIT2); else SetLow(P2OUT,BIT2); data <<= 1; data2 <<= 1; CntrB++; Pulse(P2OUT,BIT4); } else { CntrA++; if(CntrA<16) { CntrB = 1; data = gsdata[CntrA]; data2 = gsdata[(CntrA+16)]; if(data & 0x1000) SetHigh(P2OUT,BIT1); else SetLow(P2OUT,BIT1); if(data2 & 0x1000) SetHigh(P2OUT,BIT2); else SetLow(P2OUT,BIT2); data <<= 1; data2 <<= 1; Pulse(P2OUT,BIT4); } } } Pulse(P2OUT,BIT3); SetLow(P2OUT,BIT5); if(dcsent == 1) { Pulse(P2OUT,BIT4); dcsent = 2; } }
  2. Like
    SugarAddict got a reaction from zeke in TLC5940... no lights? - Solved (Code & video) (twice)   
    http://pastebin.com/0zeuLgTQ

    // I know that my commenting sucks ass... I'm not exactly working on a team project here :-P #define SetLow(port, pin) (port &= ~pin) #define SetHigh(port, pin) (port |= pin) #define Pulse(port, pin) do{SetHigh(port, pin);SetLow(port, pin);} while(0) #include "msp430g2231_mod.h" void Rotate(void); char dcdata[] = {0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F}; int gsdata[] = {0x0001, 0x0004, 0x0010, 0x0040, 0x0100, 0x0400, 0x0100, 0x0040, 0x0010, 0x0004, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; int Counter = 0, CntrA = 0, CntrB = 0, data = 0; char dcsent = 0, rotator = 0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_16MHZ; // Set range DCOCTL = CALDCO_16MHZ; // Set DCO step + modulation P1DIR |= (BIT1|BIT2|BIT3|BIT4|BIT5|BIT6|BIT7); // P1.1 XLAT, P1.5 SCLK, P1.3 BLANK, P1.4 DCPRG, P1.7 VPRG, P1.6 SIN, 1.2 GSCLK P1OUT &= ~(BIT1|BIT2|BIT4|BIT5|BIT6|BIT7); P1OUT |= (BIT3|BIT4|BIT7); CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 300; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, Up _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { Counter++; if(Counter>1024) { Counter = 0; CntrA = 0; CntrB = 0; SetHigh(P1OUT,BIT3); Pulse(P1OUT,BIT1); if(rotator) Rotate(); rotator ^= 1; } if(!dcsent) { if((CntrA == 0) && (CntrB == 0)) data = dcdata[CntrA]; if(CntrA<16) { if(CntrB<6) { if(data & 0x0020) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; CntrB++; Pulse(P1OUT,BIT5); } else { CntrA++; if(CntrA<16) { CntrB = 1; data = dcdata[CntrA]; if(data & 0x0020) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; Pulse(P1OUT,BIT5); } } } if(CntrA==16) { Pulse(P1OUT,BIT1); CntrA = 0; CntrB = 0; dcsent = 1; SetLow(P1OUT,BIT7); } } else { if((CntrA == 0) && (CntrB == 0)) data = gsdata[CntrA]; if(CntrA<16) { if(CntrB<12) { if(data & 0x0800) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; CntrB++; Pulse(P1OUT,BIT5); } else { CntrA++; if(CntrA<16) { CntrB = 1; data = gsdata[CntrA]; if(data & 0x0800) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; Pulse(P1OUT,BIT5); } } } if(CntrA == 16) { Pulse(P1OUT,BIT1); SetLow(P1OUT,BIT3); if(dcsent == 1) { Pulse(P1OUT,BIT5); dcsent = 2; } CntrA = 17; } } if(CntrA==17) Pulse(P1OUT, BIT2); } void Rotate(void) { int data = gsdata[15]; for(CntrA = 15;CntrA > 0;CntrA--) { gsdata[CntrA] = gsdata[CntrA-1]; } gsdata[0] = data; data = 0; CntrA = 0; }


  3. Like
    SugarAddict reacted to RobG in TLC5940... no lights? - Solved (Code & video) (twice)   
    Have you seen Demystifying TLC5940 book?
    I started going through it after I got my samples, but due to lack of time I was never able to put it into use.
  4. Like
    SugarAddict got a reaction from RobG in Misc (3.6v USB power, 8x8 led matrix slave)   
    So I'm missing parts for one of my boards, but here's the power one which turned out nice... that 0402 was no trouble at all and I was worried! This was me figuring out power for next weeks board.
     




     
    P.S. Don't believe the picture date, I'm too lazy to fix the camera.
  5. Like
    SugarAddict got a reaction from bluehash in TLC5940... no lights? - Solved (Code & video) (twice)   
    http://pastebin.com/0zeuLgTQ

    // I know that my commenting sucks ass... I'm not exactly working on a team project here :-P #define SetLow(port, pin) (port &= ~pin) #define SetHigh(port, pin) (port |= pin) #define Pulse(port, pin) do{SetHigh(port, pin);SetLow(port, pin);} while(0) #include "msp430g2231_mod.h" void Rotate(void); char dcdata[] = {0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F}; int gsdata[] = {0x0001, 0x0004, 0x0010, 0x0040, 0x0100, 0x0400, 0x0100, 0x0040, 0x0010, 0x0004, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; int Counter = 0, CntrA = 0, CntrB = 0, data = 0; char dcsent = 0, rotator = 0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_16MHZ; // Set range DCOCTL = CALDCO_16MHZ; // Set DCO step + modulation P1DIR |= (BIT1|BIT2|BIT3|BIT4|BIT5|BIT6|BIT7); // P1.1 XLAT, P1.5 SCLK, P1.3 BLANK, P1.4 DCPRG, P1.7 VPRG, P1.6 SIN, 1.2 GSCLK P1OUT &= ~(BIT1|BIT2|BIT4|BIT5|BIT6|BIT7); P1OUT |= (BIT3|BIT4|BIT7); CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 300; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, Up _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { Counter++; if(Counter>1024) { Counter = 0; CntrA = 0; CntrB = 0; SetHigh(P1OUT,BIT3); Pulse(P1OUT,BIT1); if(rotator) Rotate(); rotator ^= 1; } if(!dcsent) { if((CntrA == 0) && (CntrB == 0)) data = dcdata[CntrA]; if(CntrA<16) { if(CntrB<6) { if(data & 0x0020) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; CntrB++; Pulse(P1OUT,BIT5); } else { CntrA++; if(CntrA<16) { CntrB = 1; data = dcdata[CntrA]; if(data & 0x0020) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; Pulse(P1OUT,BIT5); } } } if(CntrA==16) { Pulse(P1OUT,BIT1); CntrA = 0; CntrB = 0; dcsent = 1; SetLow(P1OUT,BIT7); } } else { if((CntrA == 0) && (CntrB == 0)) data = gsdata[CntrA]; if(CntrA<16) { if(CntrB<12) { if(data & 0x0800) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; CntrB++; Pulse(P1OUT,BIT5); } else { CntrA++; if(CntrA<16) { CntrB = 1; data = gsdata[CntrA]; if(data & 0x0800) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; Pulse(P1OUT,BIT5); } } } if(CntrA == 16) { Pulse(P1OUT,BIT1); SetLow(P1OUT,BIT3); if(dcsent == 1) { Pulse(P1OUT,BIT5); dcsent = 2; } CntrA = 17; } } if(CntrA==17) Pulse(P1OUT, BIT2); } void Rotate(void) { int data = gsdata[15]; for(CntrA = 15;CntrA > 0;CntrA--) { gsdata[CntrA] = gsdata[CntrA-1]; } gsdata[0] = data; data = 0; CntrA = 0; }


  6. Like
    SugarAddict got a reaction from RobG in TLC5940... no lights? - Solved (Code & video) (twice)   
    http://pastebin.com/0zeuLgTQ

    // I know that my commenting sucks ass... I'm not exactly working on a team project here :-P #define SetLow(port, pin) (port &= ~pin) #define SetHigh(port, pin) (port |= pin) #define Pulse(port, pin) do{SetHigh(port, pin);SetLow(port, pin);} while(0) #include "msp430g2231_mod.h" void Rotate(void); char dcdata[] = {0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F}; int gsdata[] = {0x0001, 0x0004, 0x0010, 0x0040, 0x0100, 0x0400, 0x0100, 0x0040, 0x0010, 0x0004, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; int Counter = 0, CntrA = 0, CntrB = 0, data = 0; char dcsent = 0, rotator = 0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_16MHZ; // Set range DCOCTL = CALDCO_16MHZ; // Set DCO step + modulation P1DIR |= (BIT1|BIT2|BIT3|BIT4|BIT5|BIT6|BIT7); // P1.1 XLAT, P1.5 SCLK, P1.3 BLANK, P1.4 DCPRG, P1.7 VPRG, P1.6 SIN, 1.2 GSCLK P1OUT &= ~(BIT1|BIT2|BIT4|BIT5|BIT6|BIT7); P1OUT |= (BIT3|BIT4|BIT7); CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 300; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, Up _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { Counter++; if(Counter>1024) { Counter = 0; CntrA = 0; CntrB = 0; SetHigh(P1OUT,BIT3); Pulse(P1OUT,BIT1); if(rotator) Rotate(); rotator ^= 1; } if(!dcsent) { if((CntrA == 0) && (CntrB == 0)) data = dcdata[CntrA]; if(CntrA<16) { if(CntrB<6) { if(data & 0x0020) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; CntrB++; Pulse(P1OUT,BIT5); } else { CntrA++; if(CntrA<16) { CntrB = 1; data = dcdata[CntrA]; if(data & 0x0020) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; Pulse(P1OUT,BIT5); } } } if(CntrA==16) { Pulse(P1OUT,BIT1); CntrA = 0; CntrB = 0; dcsent = 1; SetLow(P1OUT,BIT7); } } else { if((CntrA == 0) && (CntrB == 0)) data = gsdata[CntrA]; if(CntrA<16) { if(CntrB<12) { if(data & 0x0800) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; CntrB++; Pulse(P1OUT,BIT5); } else { CntrA++; if(CntrA<16) { CntrB = 1; data = gsdata[CntrA]; if(data & 0x0800) SetHigh(P1OUT,BIT6); else SetLow(P1OUT,BIT6); data <<= 1; Pulse(P1OUT,BIT5); } } } if(CntrA == 16) { Pulse(P1OUT,BIT1); SetLow(P1OUT,BIT3); if(dcsent == 1) { Pulse(P1OUT,BIT5); dcsent = 2; } CntrA = 17; } } if(CntrA==17) Pulse(P1OUT, BIT2); } void Rotate(void) { int data = gsdata[15]; for(CntrA = 15;CntrA > 0;CntrA--) { gsdata[CntrA] = gsdata[CntrA-1]; } gsdata[0] = data; data = 0; CntrA = 0; }


  7. Like
    SugarAddict got a reaction from bluehash in Connector for 2013 target board with staples   
    Sorry to revive an old thread, but I found these cheapo straight's on Mouser, guess I have no excuse not to use my 2012/2013 boards now.
     






  8. Like
    SugarAddict reacted to RobG in Serial to 7 Segment LED   
    Teaser
     


  9. Like
    SugarAddict got a reaction from bluehash in Custom 8x8 led matrix   
    Got one of my orders from Dorkbot today. Figured I would drop it here since I've got some pics now
     
    I used 8 PNP (2N2906), 8 NPN (2N3904) and not what the schematic shows, that was just the footprint that worked out for me.
     
    http://www.bluedragonfire.com/smdled/Multiplex64.zip includes both board and schematic. Kudos to Err for his help on the schematic.
     





     
    Will post more when I finish soldering it and do something with it. The schematic allows for an external power source for the leds and you could battery the IC's.
     
    If you're a masochist then you could check out http://www.bluedragonfire.com/smdled/Mu ... FunBig.zip
    I'll never have it made (initial cost is too high), but I do have some other 8x8 master/slave stuff in the works
  10. Like
    SugarAddict got a reaction from RobG in Custom 8x8 led matrix   
    Got one of my orders from Dorkbot today. Figured I would drop it here since I've got some pics now
     
    I used 8 PNP (2N2906), 8 NPN (2N3904) and not what the schematic shows, that was just the footprint that worked out for me.
     
    http://www.bluedragonfire.com/smdled/Multiplex64.zip includes both board and schematic. Kudos to Err for his help on the schematic.
     





     
    Will post more when I finish soldering it and do something with it. The schematic allows for an external power source for the leds and you could battery the IC's.
     
    If you're a masochist then you could check out http://www.bluedragonfire.com/smdled/Mu ... FunBig.zip
    I'll never have it made (initial cost is too high), but I do have some other 8x8 master/slave stuff in the works
  11. Like
    SugarAddict got a reaction from syntx in Accelerometer using i2c   
    One solution would be that you can power the MSP430 with 1.8V.
     
    there is also literature you could use in reverse, as this one tells you how to use the MSP430 in a 5v circuit: http://focus.ti.com.cn/cn/lit/an/slaa148/slaa148.pdf
  12. Like
    SugarAddict got a reaction from Bellmar in Eagle first attempt...   
    Two cosmetic issues that don't match the brd, but otherwise they look pretty good!
     
     


  13. Like
    SugarAddict got a reaction from RobG in Eagle first attempt...   
    Two cosmetic issues that don't match the brd, but otherwise they look pretty good!
     
     


  14. Like
    SugarAddict got a reaction from bluehash in Eagle first attempt...   
    Two cosmetic issues that don't match the brd, but otherwise they look pretty good!
     
     


  15. Like
    SugarAddict got a reaction from jsolarski in First Serial w/ 8x8 led matrix   
    I jacked RobG's serial code from his 16 LED post and played with it some... Will probably play with it much more This is what I've done so far...
     


     
    One 74HC595 controls rows and one controls columns. Each pixel is a bit, each column is a byte, each row is a char in an array... Was the best I could think of to minimize it. It's a tad messy because I was doing different things and still am :-x But YaY, it does something
     

    // This is RobG's 16 led & 2 74HC595's code modified and played with... // A little messy and lacking commentary. #include "msp430g2231_mod.h" unsigned short TickCntr = 0; unsigned char CurCol = 0; unsigned char CurColAdd = 0; unsigned char CurRow = 0; // " M S P 4 3 0 " in 5x7 vertical binary to decimal unsigned char data[36] = {127,32,24,32,127,0,50,73,73,73,38,0,127,72,72,72,48,0,12,20,36,127,4,0,34,65,73,73,54,0,62,69,73,81,62,0}; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_16MHZ; // Set range DCOCTL = CALDCO_16MHZ; // Set DCO step + modulation P1OUT |= 0x01; // Port P1.0 will be used to latch P1DIR |= 0x01; USICTL0 |= USIPE6 + USIPE5 + USIMST + USIOE; // Out & clk enable, SPI Master USICTL1 |= USICKPH + USIIE; // Counter interrupt // USICKCTL = USIDIV_7 + USISSEL_2; // /2 SMCLK USICKCTL = USIDIV_0 + USISSEL_2; // /2 SMCLK USICTL0 &= ~USISWRST; // Enable USI USICNT = USI16B; // Enable 16 bit CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 272; // Duration (16*16+16, I don't know the reasoning but it's what appears to be the lowest that works with some buffer in case of delays) // TACTL = TASSEL_2 + MC_1 + ID_3; // SMCLK, upmode TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, upmode _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { unsigned int Output = 0xFF00; // make it blank in case of an error TickCntr++; // count the ticks if(TickCntr>9000) // did we hit 9000 ticks? { // We did, lets reset and increase the column for rotation TickCntr=0; CurCol++; CurColAdd = 0; // this helps with some jitter since I didn't do a smoother method if(CurCol>35)CurCol = 0; } CurRow>>=1; // bitwise shift the row from last go around if((CurCol+CurColAdd)>35) // make sure we don't try to read more than we should { if((CurRow&data[(CurCol+CurColAdd)-36]) == CurRow) // go back to 0 column { Output = CurRow^0xFF; // XOR the row Output<<=8; // shift the row data over Output |= (0x80>>CurColAdd); // Shift the column into place } } else { if((CurRow&data[CurCol+CurColAdd]) == CurRow) // repeat but without the minus { Output = CurRow^0xFF; Output<<=8; Output |= (0x80>>CurColAdd); } } if(CurRow==0) // if we did the last row lets reset that { CurRow=0x80; CurColAdd++; // increase the column we're working on if(CurColAdd>7)CurColAdd=0; // reset the column we're working on } USISR = Output; //USISR = unsigned int (16 bits) USICNT |= 16; // Start USI } // USI interrupt service routine #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { USICTL1 &= ~USIIFG; // Clear pending flag P1OUT &= ~0x01; // Latch data P1OUT |= 0x01; }
  16. Like
    SugarAddict got a reaction from bluehash in First Serial w/ 8x8 led matrix   
    I jacked RobG's serial code from his 16 LED post and played with it some... Will probably play with it much more This is what I've done so far...
     


     
    One 74HC595 controls rows and one controls columns. Each pixel is a bit, each column is a byte, each row is a char in an array... Was the best I could think of to minimize it. It's a tad messy because I was doing different things and still am :-x But YaY, it does something
     

    // This is RobG's 16 led & 2 74HC595's code modified and played with... // A little messy and lacking commentary. #include "msp430g2231_mod.h" unsigned short TickCntr = 0; unsigned char CurCol = 0; unsigned char CurColAdd = 0; unsigned char CurRow = 0; // " M S P 4 3 0 " in 5x7 vertical binary to decimal unsigned char data[36] = {127,32,24,32,127,0,50,73,73,73,38,0,127,72,72,72,48,0,12,20,36,127,4,0,34,65,73,73,54,0,62,69,73,81,62,0}; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_16MHZ; // Set range DCOCTL = CALDCO_16MHZ; // Set DCO step + modulation P1OUT |= 0x01; // Port P1.0 will be used to latch P1DIR |= 0x01; USICTL0 |= USIPE6 + USIPE5 + USIMST + USIOE; // Out & clk enable, SPI Master USICTL1 |= USICKPH + USIIE; // Counter interrupt // USICKCTL = USIDIV_7 + USISSEL_2; // /2 SMCLK USICKCTL = USIDIV_0 + USISSEL_2; // /2 SMCLK USICTL0 &= ~USISWRST; // Enable USI USICNT = USI16B; // Enable 16 bit CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 272; // Duration (16*16+16, I don't know the reasoning but it's what appears to be the lowest that works with some buffer in case of delays) // TACTL = TASSEL_2 + MC_1 + ID_3; // SMCLK, upmode TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, upmode _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { unsigned int Output = 0xFF00; // make it blank in case of an error TickCntr++; // count the ticks if(TickCntr>9000) // did we hit 9000 ticks? { // We did, lets reset and increase the column for rotation TickCntr=0; CurCol++; CurColAdd = 0; // this helps with some jitter since I didn't do a smoother method if(CurCol>35)CurCol = 0; } CurRow>>=1; // bitwise shift the row from last go around if((CurCol+CurColAdd)>35) // make sure we don't try to read more than we should { if((CurRow&data[(CurCol+CurColAdd)-36]) == CurRow) // go back to 0 column { Output = CurRow^0xFF; // XOR the row Output<<=8; // shift the row data over Output |= (0x80>>CurColAdd); // Shift the column into place } } else { if((CurRow&data[CurCol+CurColAdd]) == CurRow) // repeat but without the minus { Output = CurRow^0xFF; Output<<=8; Output |= (0x80>>CurColAdd); } } if(CurRow==0) // if we did the last row lets reset that { CurRow=0x80; CurColAdd++; // increase the column we're working on if(CurColAdd>7)CurColAdd=0; // reset the column we're working on } USISR = Output; //USISR = unsigned int (16 bits) USICNT |= 16; // Start USI } // USI interrupt service routine #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { USICTL1 &= ~USIIFG; // Clear pending flag P1OUT &= ~0x01; // Latch data P1OUT |= 0x01; }
  17. Like
    SugarAddict reacted to RobG in MSP430 LaunchPad, 74HC595, 16 LEDs   
    What is it?
    4 digit BCD counter using LaunchPad and two 74HC595 shift registers.
     
    Note: One important thing that I forgot to add is that since I am powering this from LP, I am using here 74HC595 and not HCT.
    LP provides 3.6V, HCT needs 5V.
     
    See it in action:


     

    #include unsigned int counter = 0; // Counter variable void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1OUT |= 0x01; // Port P1.0 will be used to latch P1DIR |= 0x01; USICTL0 |= USIPE6 + USIPE5 + USIMST + USIOE; // Out & clk enable, SPI Master USICTL1 |= USICKPH + USIIE; // Counter interrupt USICKCTL = USIDIV_7 + USISSEL_2; // /2 SMCLK USICTL0 &= ~USISWRST; // Enable USI USICNT = USI16B; // Enable 16 bit CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 10000; // Duration TACTL = TASSEL_2 + MC_1 + ID_3; // SMCLK, upmode _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { counter = _bcd_add_short(counter, 0x01); // Decimally increase counter's value USISR = counter; USICNT |= 16; // Start USI } // USI interrupt service routine #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { USICTL1 &= ~USIIFG; // Clear pending flag P1OUT &= ~0x01; // Latch data P1OUT |= 0x01; }
     
    In the coming parts, I will be increasing the number of digits to 8 and changing LEDs to 7-segment displays, maybe throw in a keyboard.

  18. Like
    SugarAddict got a reaction from RobG in First Serial w/ 8x8 led matrix   
    I jacked RobG's serial code from his 16 LED post and played with it some... Will probably play with it much more This is what I've done so far...
     


     
    One 74HC595 controls rows and one controls columns. Each pixel is a bit, each column is a byte, each row is a char in an array... Was the best I could think of to minimize it. It's a tad messy because I was doing different things and still am :-x But YaY, it does something
     

    // This is RobG's 16 led & 2 74HC595's code modified and played with... // A little messy and lacking commentary. #include "msp430g2231_mod.h" unsigned short TickCntr = 0; unsigned char CurCol = 0; unsigned char CurColAdd = 0; unsigned char CurRow = 0; // " M S P 4 3 0 " in 5x7 vertical binary to decimal unsigned char data[36] = {127,32,24,32,127,0,50,73,73,73,38,0,127,72,72,72,48,0,12,20,36,127,4,0,34,65,73,73,54,0,62,69,73,81,62,0}; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_16MHZ; // Set range DCOCTL = CALDCO_16MHZ; // Set DCO step + modulation P1OUT |= 0x01; // Port P1.0 will be used to latch P1DIR |= 0x01; USICTL0 |= USIPE6 + USIPE5 + USIMST + USIOE; // Out & clk enable, SPI Master USICTL1 |= USICKPH + USIIE; // Counter interrupt // USICKCTL = USIDIV_7 + USISSEL_2; // /2 SMCLK USICKCTL = USIDIV_0 + USISSEL_2; // /2 SMCLK USICTL0 &= ~USISWRST; // Enable USI USICNT = USI16B; // Enable 16 bit CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 272; // Duration (16*16+16, I don't know the reasoning but it's what appears to be the lowest that works with some buffer in case of delays) // TACTL = TASSEL_2 + MC_1 + ID_3; // SMCLK, upmode TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, upmode _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { unsigned int Output = 0xFF00; // make it blank in case of an error TickCntr++; // count the ticks if(TickCntr>9000) // did we hit 9000 ticks? { // We did, lets reset and increase the column for rotation TickCntr=0; CurCol++; CurColAdd = 0; // this helps with some jitter since I didn't do a smoother method if(CurCol>35)CurCol = 0; } CurRow>>=1; // bitwise shift the row from last go around if((CurCol+CurColAdd)>35) // make sure we don't try to read more than we should { if((CurRow&data[(CurCol+CurColAdd)-36]) == CurRow) // go back to 0 column { Output = CurRow^0xFF; // XOR the row Output<<=8; // shift the row data over Output |= (0x80>>CurColAdd); // Shift the column into place } } else { if((CurRow&data[CurCol+CurColAdd]) == CurRow) // repeat but without the minus { Output = CurRow^0xFF; Output<<=8; Output |= (0x80>>CurColAdd); } } if(CurRow==0) // if we did the last row lets reset that { CurRow=0x80; CurColAdd++; // increase the column we're working on if(CurColAdd>7)CurColAdd=0; // reset the column we're working on } USISR = Output; //USISR = unsigned int (16 bits) USICNT |= 16; // Start USI } // USI interrupt service routine #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { USICTL1 &= ~USIIFG; // Clear pending flag P1OUT &= ~0x01; // Latch data P1OUT |= 0x01; }
  19. Like
    SugarAddict reacted to GeekDoc in Eagle first attempt...   
    I'll have a look at them. Just so you know, you can adjust traces once they autoroute. I ended up doing most of mine by hand because autoroute comes out kind of convoluted sometimes.
     
    Edit: They look fine. There are a few unnecessary vias, and some of the clearances are a bit tight for my taste, but that's what you get with autoroute. Make sure to get a rules file from your manufacturer to run against this design so you can be sure the tolerances are okay. Also, you may want thicker traces on those carrying higher currents; all of the traces in your designs are pretty thin (autoroute strikes again).
     
    BTW: To show your board, you only need send the board (.brd) file; it's self-contained and editable. If you want to allow someone to change the design (components, connections, etc.), include the schematic (.sch) file as well. The two files are all you need for your project; the remainder are mostly backups from changes.
  20. Like
    SugarAddict got a reaction from bluehash in MSP430F2274 TSSOP 38 Breakout board?   
    Oh, pics I can do... Went ahead and soldered male headers to the bottom of a launchpad while I was at it... so much easier to use now on the breadboard.



  21. Like
    SugarAddict got a reaction from bluehash in MSP430F2274 TSSOP 38 Breakout board?   
    I got my EZPrototype box today, I ordered the right stuff :-) I soldered one of the tssop's right off and got it working with spy-bi-wire to blink a led on p1.0... Guess I need to test all the pins now since I've got no magnifying glass, hehe. Price wasn't too bad and it got here fairly quick... Only thing I had fun with is that the pads are pin edge to pin edge with this chip, so I was tapping the pin tops to solder vs tapping the pin tips and pad (coming in from top instead of coming in at angle/side).
     
    Maybe I'll take a pot shot at the qfn chip I got a board for (3x3) but not today, I'm pushing my luck
     
    I'm happy
×
×
  • Create New...