Jump to content
43oh

jsolarski

Members
  • Content Count

    568
  • Joined

  • Last visited

  • Days Won

    8

Reputation Activity

  1. Like
    jsolarski reacted to RobG in LaunchPad, ADC, and LCD   
    It's time to play with ADC. I put together 2 examples, single channel and sequence of channels.Both use Vcc as reference.
    In the first example value of ADC10MEM register is displayed and the same value converted to show actual voltage.
    In the second example, 4 inputs are sampled, values are not converted, binary data is displayed (don't get fooled by the period.)


     
    #include "msp430g2231.h" #define sendData(data) send(data, 1) #define sendInstruction(data) send(data, 0) #define initDisplay() sendInstruction(0x3C); sendInstruction(0x0C); clearDisplay(); sendInstruction(0x06) #define clearDisplay() sendInstruction(0x01); _delay_cycles(2000) #define DATAPIN BIT6 #define CLOCKPIN BIT5 #define ENABLEPIN BIT4 const char charMap[10] = { 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39 }; void send(char data, char registerSelect); void sendDataArray(char data[], char length); char charIndex = 0; char bitCounter = 0; char charsToSend[5] = {0,0,0,0,0}; void main(void) { WDTCTL = WDTPW + WDTHOLD; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; _delay_cycles(100000); P1OUT &= ~(CLOCKPIN + DATAPIN); P1OUT |= ENABLEPIN; P1DIR |= ENABLEPIN + CLOCKPIN + DATAPIN; initDisplay(); ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE; ADC10CTL1 = INCH_1; ADC10AE0 |= BIT1; CCTL0 = CCIE; CCR0 = 12500; TACTL = TASSEL_2 + MC_1 + ID_3; _bis_SR_register(LPM0_bits + GIE); } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { clearDisplay(); charIndex = 0; while(charIndex < 4) { charsToSend[charIndex] = charMap[0]; charIndex++; } unsigned int binary = ADC10MEM; charIndex = 3; while(binary > 0) { charsToSend[charIndex] = charMap[binary % 10]; binary /= 10; charIndex--; } sendDataArray(charsToSend, 4); charIndex = 0; while(charIndex < 5) { charsToSend[charIndex] = charMap[0]; charIndex++; } charsToSend[1] = 0x2E; binary = ADC10MEM * 3.52; charIndex = 4; while(binary > 0) { charsToSend[charIndex] = charMap[binary % 10]; binary /= 10; charIndex--; if(charIndex == 1) charIndex--; } sendInstruction(0xC0); sendDataArray(charsToSend, 5); sendData(0x56); } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { ADC10CTL0 |= ENC + ADC10SC; } void sendDataArray(char data[], char length) { charIndex = 0; while(charIndex < length) { sendData(data[charIndex]); charIndex++; } } void send(char data, char registerSelect) { bitCounter = 0; while(bitCounter < 8) { (data & BIT7) ? (P1OUT |= DATAPIN) : (P1OUT &= ~DATAPIN); data <<= 1; P1OUT |= CLOCKPIN; P1OUT &= ~CLOCKPIN; bitCounter++; } registerSelect ? (P1OUT |= DATAPIN) : (P1OUT &= ~DATAPIN); P1OUT &= ~ENABLEPIN; P1OUT |= ENABLEPIN; }


    #include "msp430g2231.h" #define sendData(data) send(data, 1) #define sendInstruction(data) send(data, 0) #define initDisplay() sendInstruction(0x3C); sendInstruction(0x0C); clearDisplay(); sendInstruction(0x06) #define clearDisplay() sendInstruction(0x01); _delay_cycles(2000) #define DATAPIN BIT6 #define CLOCKPIN BIT5 #define ENABLEPIN BIT4 const char charMap[10] = { 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39 }; const char addressMap[4] = { 0x80, 0x88, 0xC0, 0xC8 }; void send(char data, char registerSelect); void sendDataArray(char data[], char length); char charIndex = 0; char valueIndex = 0; char bitCounter = 0; char charsToSend[5] = {0,0,0,0,0}; int values[4] = {0,0,0,0}; void main(void) { WDTCTL = WDTPW + WDTHOLD; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; _delay_cycles(100000); P1OUT &= ~(CLOCKPIN + DATAPIN); P1OUT |= ENABLEPIN; P1DIR |= ENABLEPIN + CLOCKPIN + DATAPIN; initDisplay(); ADC10CTL1 = INCH_3 + CONSEQ_1; ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE; ADC10DTC1 = 0x04; ADC10AE0 |= 0x0F; CCTL0 = CCIE; CCR0 = 12500; TACTL = TASSEL_2 + MC_1 + ID_3; _bis_SR_register(LPM0_bits + GIE); } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { clearDisplay(); while (ADC10CTL1 & BUSY) ; valueIndex = 0; while(valueIndex < 4) { charIndex = 0; while(charIndex < 5) { charsToSend[charIndex] = charMap[0]; charIndex++; } charsToSend[1] = 0x2E; unsigned int binary = values[valueIndex]; charIndex = 4; while(binary > 0) { charsToSend[charIndex] = charMap[binary % 10]; binary /= 10; charIndex--; if(charIndex == 1) charIndex--; } sendInstruction(addressMap[valueIndex]); sendDataArray(charsToSend, 5); valueIndex++; } } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { ADC10CTL0 &= ~ENC; while (ADC10CTL1 & BUSY) ; ADC10SA = (unsigned int)&values[0]; ADC10CTL0 |= ENC + ADC10SC; } void sendDataArray(char data[], char length) { charIndex = 0; while(charIndex < length) { sendData(data[charIndex]); charIndex++; } } void send(char data, char registerSelect) { bitCounter = 0; while(bitCounter < 8) { (data & BIT7) ? (P1OUT |= DATAPIN) : (P1OUT &= ~DATAPIN); data <<= 1; P1OUT |= CLOCKPIN; P1OUT &= ~CLOCKPIN; bitCounter++; } registerSelect ? (P1OUT |= DATAPIN) : (P1OUT &= ~DATAPIN); P1OUT &= ~ENABLEPIN; P1OUT |= ENABLEPIN; }
  2. Like
    jsolarski reacted to linuxha in MSP430, mspgcc and Linux   
    I've started to put together my MSP430 notes page. It's no where near completed (technically it isn't published yet) but it does contain my working Makefile and a converted TI blink program for the F2012. I've commented out the TI code that doesn't work (the #pragma for example). I'll work on it as I get time. The program is decent to test out the compiled, the mspdebug (loading, running, step, etc.). It worked well on my Ubuntu client. On my server there is a problem with getting the USB stick recognized. I still have a lot of work to do on the page.
  3. Like
    jsolarski reacted to butterfingers in TI launches video repository (from Dangerous Prototypes)   
    Texas Instruments has announced a new video website:
     
    TI recently launched a new video repository which really takes us to the next level in online video. This new system (which can be found at http://videos.ti.com) creates a one-stop-shop for seeing all the video content, High quality video streaming with full screen capability. Share functionality which will allow you to post the video right in the player to many popular social sharing sites. Email functionality which will allow you to email the video to friends who might also find it of interest. Embed codes which allow you to place the video on your own pages. But one of the key new items which we are now offering our customers is User Generated Video. If you make any videos about how to use TI products we want you to upload them to our site! Simply go to http://uploadvideo.ti.com and load your file! We
  4. Like
    jsolarski reacted to RobG in C/C++ Formatter   
    After spending more and more time with my LaunchPad and CCS, I started to miss one of the features I use daily in my Eclipse, code formatter. CCS does not come with a built-in one, but there are plug-ins available. The one I found is called Astyleand it works pretty well.
     
    To install it:
    Help -> Software Updates -> Find and Install... -> Search for new features... -> New Remote Site
    Name can be Astyle, URL: http://astyleclipse.sourceforge.net/update
    Finish, agree, install, restart, etc.
    After restart:
    Window -> Preferences... -> C/C++ -> Code Formatter -> Formatters -> Astyle Plugin, Apply and OK.
    In Preferences -> Astyle, you can choose the actual style, kr in my opinion is the best.
    To format, Ctrl-Shift-F
     
    Enjoy nice code! ( doesn't mean bug free )
  5. Like
    jsolarski reacted to zeke in getting printf() working   
    In the last couple of days, I have collected some primo information on this topic and I thought I should post links so others could benefit.
     
    1. how to point printf to UART on MSP430F1232
    2. Help! CCS4.0 with MSP430F2252 has Trouble with 32 bit (Long) Data.
    3. IAR AppNote 430-03
    4. Tips for using printf
    5. Printf support in compiler
    6. printf on msp430
     
    Today, I was able to successfully test the solution presented at link 2 but it took a lot of flash space.
    MSP430: Program loaded. Code Size - Text: 3024 bytes Data: 774 bytes
     
    Good thing the F5438 has a lot of flash.
     
     
    There is one more method that I would like to try. It's a combination of link 6 and some ideas my mentor had. Stay tuned.
  6. Like
    jsolarski reacted to zeke in success! - Identified 17 devices on 1 Wire Bus   
    Today is a good day.
     
    1. I got my 1-wire search algorithm working. I have been able to successfully identify 17 devices on the 1-wire bus.
    2. I discovered that DS1821's cannot be searched for on the 1-wire bus. Their presence kills the search algorithm.
    3. I got my hardware UART baudrate config routines sorted out. I can run between 9600 and 460800 Baud.
    3. I love this Saleae Logic analyzer that I got last Friday. What a life saver!
     
    Here's a screenshot of it showing 10 1-Wire sensors during the search routine.

     
    Here's what the output looks like for 17 sensors:

    PacketId, Time[s], Detail, [data] 0,0,Reset Pulse 0,0.0005115,Presence Pulse 1,0.00097,Reset Pulse 1,0.001481,Presence Pulse 1,0.001944,Search Rom Command, 0xF0 1,0.002529,ROM Family Code, 0x10 1,0.004464,ROM Code, 0x0008022E69B2 1,0.016032,ROM CRC, 0x2C 2,0.01798,Reset Pulse 2,0.01849,Presence Pulse 2,0.0189535,Search Rom Command, 0xF0 2,0.0195385,ROM Family Code, 0x10 2,0.021476,ROM Code, 0x0008022E6C86 2,0.033045,ROM CRC, 0xCF 3,0.0349955,Reset Pulse 3,0.035506,Presence Pulse 3,0.0359695,Search Rom Command, 0xF0 3,0.036554,ROM Family Code, 0x28 3,0.0384905,ROM Code, 0x000002E13980 3,0.0500605,ROM CRC, 0x0A 4,0.0520075,Reset Pulse 4,0.052518,Presence Pulse 4,0.0529815,Search Rom Command, 0xF0 4,0.053566,ROM Family Code, 0x28 4,0.0555025,ROM Code, 0x0000030F101A 4,0.0670725,ROM CRC, 0x88 5,0.06902,Reset Pulse 5,0.0695305,Presence Pulse 5,0.0699935,Search Rom Command, 0xF0 5,0.070579,ROM Family Code, 0x28 5,0.072516,ROM Code, 0x0000030F08EB 5,0.084089,ROM CRC, 0x8F 6,0.086038,Reset Pulse 6,0.086549,Presence Pulse 6,0.0870115,Search Rom Command, 0xF0 6,0.0875965,ROM Family Code, 0x1C 6,0.089529,ROM Code, 0x00000537A27F 6,0.101104,ROM CRC, 0x09 7,0.1030515,Reset Pulse 7,0.103562,Presence Pulse 7,0.1040255,Search Rom Command, 0xF0 7,0.104611,ROM Family Code, 0x1C 7,0.1065445,ROM Code, 0x0000052C4D7F 7,0.1181165,ROM CRC, 0x10 8,0.120063,Reset Pulse 8,0.1205735,Presence Pulse 8,0.121037,Search Rom Command, 0xF0 8,0.1216225,ROM Family Code, 0x22 8,0.123555,ROM Code, 0x0000002A3ACB 8,0.1351255,ROM CRC, 0xA0 9,0.137074,Reset Pulse 9,0.137585,Presence Pulse 9,0.1380485,Search Rom Command, 0xF0 9,0.138634,ROM Family Code, 0x22 9,0.1405665,ROM Code, 0x0000002A702F 9,0.152135,ROM CRC, 0x01 10,0.1540815,Reset Pulse 10,0.1545915,Presence Pulse 10,0.1550545,Search Rom Command, 0xF0 10,0.15564,ROM Family Code, 0x01 10,0.157573,ROM Code, 0x000013B1FBEC 10,0.1691465,ROM CRC, 0x0F 11,0.1710955,Reset Pulse 11,0.1716065,Presence Pulse 11,0.17207,Search Rom Command, 0xF0 11,0.172655,ROM Family Code, 0x01 11,0.174589,ROM Code, 0x000013B22BDC 11,0.1861595,ROM CRC, 0x34 12,0.188107,Reset Pulse 12,0.188617,Presence Pulse 12,0.18908,Search Rom Command, 0xF0 12,0.1896645,ROM Family Code, 0x2D 12,0.1915995,ROM Code, 0x00000209FB06 12,0.203172,ROM CRC, 0x6F 13,0.205121,Reset Pulse 13,0.2056315,Presence Pulse 13,0.2060945,Search Rom Command, 0xF0 13,0.2066795,ROM Family Code, 0x2D 13,0.208614,ROM Code, 0x0000020A0E5F 13,0.220185,ROM CRC, 0x2B 14,0.2221335,Reset Pulse 14,0.2226435,Presence Pulse 14,0.2231065,Search Rom Command, 0xF0 14,0.223692,ROM Family Code, 0x43 14,0.2256255,ROM Code, 0x0000001E305C 14,0.2371975,ROM CRC, 0x7A 15,0.2391465,Reset Pulse 15,0.2396565,Presence Pulse 15,0.24012,Search Rom Command, 0xF0 15,0.2407055,ROM Family Code, 0x43 15,0.2426395,ROM Code, 0x0000001E286B 15,0.2542075,ROM CRC, 0x50 16,0.256154,Reset Pulse 16,0.2566645,Presence Pulse 16,0.2571275,Search Rom Command, 0xF0 16,0.257713,ROM Family Code, 0x23 16,0.259645,ROM Code, 0x000000F0D232 16,0.271214,ROM CRC, 0x87 ,0.273162,Reset Pulse ,0.273673,Presence Pulse ,0.2741355,Search Rom Command, 0xF0 ,0.2747205,ROM Family Code, 0x23 ,0.2766535,ROM Code, 0x000000F0BCC3 ,0.2882255,ROM CRC, 0x71
     
    Today is a good day.

     
    Next on the list is the dreaded printf().
  7. Like
    jsolarski reacted to butterfingers in Mac to LaunchPad transfers - options? More TI support?   
    Yes, it seems to run OK. I think the error is because the LaunchPad is similar to, but not exactly the same as, the rf2500. This is about as small and simple as code can be, so I'll have to hope that it'll keep working if I do something more complex.
     
    Old stats on the Arduino site, for example, show that just over a quarter of visitors are using Macs. If you infer that they're developing on the same OS as they visit on, then that's a lot of untapped audience for TI to target. What I'll try to do next is get msp430-gcc and mspdebug working cleanly with XCode, then write up a howto.
  8. Like
    jsolarski reacted to cde in MSP430 comunicate via SMBus   
    SMBus is just a stricter (and somewhat looser in other terms) I2C with an extra feature or two. Check out the code examples for the valueline chips, and you will see one or two smbus examples.
     
    Also
    slaa249a
    slaa073
     
    But the most important one to look for is the datasheet of the target ic you need to talk to.
  9. Like
    jsolarski reacted to linuxha in MSP430 tools for linux   
    But I only figured it out when I was forced to think it through enough to explain what was going on (typical). Then I was forced to prove my answers. I hate posting something and then getting asked the obvious question (did you do this or that). I can make enough of a fool of myself without the extra added effort.
  10. Like
    jsolarski got a reaction from linuxha in MSP430 tools for linux   
    Original Post http://justinstech.org/2010/07/msp430-tools-for-linux/
    The MSP430, has a working compiler and tool chain for the MSP430 uC
     
    you can find the Tools here http://mspgcc4.sourceforge.net/
    and you can find the debugger/programmer here http://mspdebug.sourceforge.net/
     
     
    sources used -
    http://losinggeneration.homelinux.org/2010/07/02/msp430-launchpad-on-linux/
    http://eclecti.cc/hardware/using-the-ti-msp430-launchpad-with-ubuntu-10-04
  11. Like
    jsolarski reacted to sucotronic in Playing music   
    I've written a simple program adapted from the rttl example in the Arduino Tone library. It only need a launchpad, a piezo buzzer and a compiler (in my case mspgcc). You take a look in my blog(I don't want to seem spam, only want to share with others my madness .P).
     


     

    /* Buzzer example */ #include #include typedef unsigned char byte; #define NOTE_B0 31 #define NOTE_C1 33 #define NOTE_CS1 35 #define NOTE_D1 37 #define NOTE_DS1 39 #define NOTE_E1 41 #define NOTE_F1 44 #define NOTE_FS1 46 #define NOTE_G1 49 #define NOTE_GS1 52 #define NOTE_A1 55 #define NOTE_AS1 58 #define NOTE_B1 62 #define NOTE_C2 65 #define NOTE_CS2 69 #define NOTE_D2 73 #define NOTE_DS2 78 #define NOTE_E2 82 #define NOTE_F2 87 #define NOTE_FS2 93 #define NOTE_G2 98 #define NOTE_GS2 104 #define NOTE_A2 110 #define NOTE_AS2 117 #define NOTE_B2 123 #define NOTE_C3 131 #define NOTE_CS3 139 #define NOTE_D3 147 #define NOTE_DS3 156 #define NOTE_E3 165 #define NOTE_F3 175 #define NOTE_FS3 185 #define NOTE_G3 196 #define NOTE_GS3 208 #define NOTE_A3 220 #define NOTE_AS3 233 #define NOTE_B3 247 #define NOTE_C4 262 #define NOTE_CS4 277 #define NOTE_D4 294 #define NOTE_DS4 311 #define NOTE_E4 330 #define NOTE_F4 349 #define NOTE_FS4 370 #define NOTE_G4 392 #define NOTE_GS4 415 #define NOTE_A4 440 #define NOTE_AS4 466 #define NOTE_B4 494 #define NOTE_C5 523 #define NOTE_CS5 554 #define NOTE_D5 587 #define NOTE_DS5 622 #define NOTE_E5 659 #define NOTE_F5 698 #define NOTE_FS5 740 #define NOTE_G5 784 #define NOTE_GS5 831 #define NOTE_A5 880 #define NOTE_AS5 932 #define NOTE_B5 988 #define NOTE_C6 1047 #define NOTE_CS6 1109 #define NOTE_D6 1175 #define NOTE_DS6 1245 #define NOTE_E6 1319 #define NOTE_F6 1397 #define NOTE_FS6 1480 #define NOTE_G6 1568 #define NOTE_GS6 1661 #define NOTE_A6 1760 #define NOTE_AS6 1865 #define NOTE_B6 1976 #define NOTE_C7 2093 #define NOTE_CS7 2217 #define NOTE_D7 2349 #define NOTE_DS7 2489 #define NOTE_E7 2637 #define NOTE_F7 2794 #define NOTE_FS7 2960 #define NOTE_G7 3136 #define NOTE_GS7 3322 #define NOTE_A7 3520 #define NOTE_AS7 3729 #define NOTE_B7 3951 #define NOTE_C8 4186 #define NOTE_CS8 4435 #define NOTE_D8 4699 #define NOTE_DS8 4978 #define OCTAVE_OFFSET 0 int notes[] = { 0, NOTE_C4, NOTE_CS4, NOTE_D4, NOTE_DS4, NOTE_E4, NOTE_F4, NOTE_FS4, NOTE_G4, NOTE_GS4, NOTE_A4, NOTE_AS4, NOTE_B4, NOTE_C5, NOTE_CS5, NOTE_D5, NOTE_DS5, NOTE_E5, NOTE_F5, NOTE_FS5, NOTE_G5, NOTE_GS5, NOTE_A5, NOTE_AS5, NOTE_B5, NOTE_C6, NOTE_CS6, NOTE_D6, NOTE_DS6, NOTE_E6, NOTE_F6, NOTE_FS6, NOTE_G6, NOTE_GS6, NOTE_A6, NOTE_AS6, NOTE_B6, NOTE_C7, NOTE_CS7, NOTE_D7, NOTE_DS7, NOTE_E7, NOTE_F7, NOTE_FS7, NOTE_G7, NOTE_GS7, NOTE_A7, NOTE_AS7, NOTE_B7 }; //char *song = "The Simpsons:d=4,o=5,b=160:c.6,e6,f#6,8a6,g.6,e6,c6,8a,8f#,8f#,8f#,2g,8p,8p,8f#,8f#,8f#,8g,a#.,8c6,8c6,8c6,c6"; //char *song = "Indiana:d=4,o=5,b=250:e,8p,8f,8g,8p,1c6,8p.,d,8p,8e,1f,p.,g,8p,8a,8b,8p,1f6,p,a,8p,8b,2c6,2d6,2e6,e,8p,8f,8g,8p,1c6,p,d6,8p,8e6,1f.6,g,8p,8g,e.6,8p,d6,8p,8g,e.6,8p,d6,8p,8g,f.6,8p,e6,8p,8d6,2c6"; //char *song = "TakeOnMe:d=4,o=4,b=160:8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5,8f#5,8e5,8f#5,8f#5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5"; //char *song = "Entertainer:d=4,o=5,b=140:8d,8d#,8e,c6,8e,c6,8e,2c.6,8c6,8d6,8d#6,8e6,8c6,8d6,e6,8b,d6,2c6,p,8d,8d#,8e,c6,8e,c6,8e,2c.6,8p,8a,8g,8f#,8a,8c6,e6,8d6,8c6,8a,2d6"; //char *song = "Muppets:d=4,o=5,b=250:c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,8a,8p,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,8e,8p,8e,g,2p,c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,a,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,d,8d,c"; //char *song = "Xfiles:d=4,o=5,b=125:e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,g6,f#6,e6,d6,e6,2b.,1p,g6,f#6,e6,d6,f#6,2b.,1p,e,b,a,b,d6,2b.,1p,e,b,a,b,e6,2b.,1p,e6,2b."; //char *song = "Looney:d=4,o=5,b=140:32p,c6,8f6,8e6,8d6,8c6,a.,8c6,8f6,8e6,8d6,8d#6,e.6,8e6,8e6,8c6,8d6,8c6,8e6,8c6,8d6,8a,8c6,8g,8a#,8a,8f"; //char *song = "20thCenFox:d=16,o=5,b=140:b,8p,b,b,2b,p,c6,32p,b,32p,c6,32p,b,32p,c6,32p,b,8p,b,b,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,g#,32p,a,32p,b,8p,b,b,2b,4p,8e,8g#,8b,1c#6,8f#,8a,8c#6,1e6,8a,8c#6,8e6,1e6,8b,8g#,8a,2b"; //char *song = "Bond:d=4,o=5,b=80:32p,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d#6,16d#6,16c#6,32d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6,32e6,16e6,8e6,16d#6,16d6,16c#6,16c#7,c.7,16g#6,16f#6,g#.6"; //char *song = "MASH:d=8,o=5,b=140:4a,4g,f#,g,p,f#,p,g,p,f#,p,2e.,p,f#,e,4f#,e,f#,p,e,p,4d.,p,f#,4e,d,e,p,d,p,e,p,d,p,2c#.,p,d,c#,4d,c#,d,p,e,p,4f#,p,a,p,4b,a,b,p,a,p,b,p,2a.,4p,a,b,a,4b,a,b,p,2a.,a,4f#,a,b,p,d6,p,4e.6,d6,b,p,a,p,2b"; //char *song = "StarWars:d=4,o=5,b=45:32p,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#.6,32f#,32f#,32f#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#6"; //char *song = "GoodBad:d=4,o=5,b=56:32p,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,d#,32a#,32d#6,32a#,32d#6,8a#.,16f#.,16g#.,c#6,32a#,32d#6,32a#,32d#6,8a#.,16f#.,32f.,32d#.,c#,32a#,32d#6,32a#,32d#6,8a#.,16g#.,d#"; //char *song = "TopGun:d=4,o=4,b=31:32p,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,16f,d#,16c#,16g#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16f,32d#,32f,16f#,32f,32c#,g#"; //char *song = "A-Team:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#"; //char *song = "Flinstones:d=4,o=5,b=40:32p,16f6,16a#,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,d6,16f6,16a#.,16a#6,32g6,16f6,16a#.,32f6,32f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c6,a#,16a6,16d.6,16a#6,32a6,32a6,32g6,32f#6,32a6,8g6,16g6,16c.6,32a6,32a6,32g6,32g6,32f6,32e6,32g6,8f6,16f6,16a#.,16a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,32f6,16a#6,16c7,8a#.6"; //char *song = "Jeopardy:d=4,o=6,b=125:c,f,c,f5,c,f,2c,c,f,c,f,a.,8g,8f,8e,8d,8c#,c,f,c,f5,c,f,2c,f.,8d,c,a#5,a5,g5,f5,p,d#,g#,d#,g#5,d#,g#,2d#,d#,g#,d#,g#,c.7,8a#,8g#,8g,8f,8e,d#,g#,d#,g#5,d#,g#,2d#,g#.,8f,d#,c#,c,p,a#5,p,g#.5,d#,g#"; //char *song = "Gadget:d=16,o=5,b=50:32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,32d#,32f,32f#,32g#,a#,d#6,4d6,32d#,32f,32f#,32g#,a#,f#,a,f,g#,f#,8d#"; //char *song = "Smurfs:d=32,o=5,b=200:4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8f#,p,8a#,p,4g#,4p,g#,p,a#,p,b,p,c6,p,4c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p,8b,p,8f,p,4f#"; //char *song = "MahnaMahna:d=16,o=6,b=125:c#,c.,b5,8a#.5,8f.,4g#,a#,g.,4d#,8p,c#,c.,b5,8a#.5,8f.,g#.,8a#.,4g,8p,c#,c.,b5,8a#.5,8f.,4g#,f,g.,8d#.,f,g.,8d#.,f,8g,8d#.,f,8g,d#,8c,a#5,8d#.,8d#.,4d#,8d#."; //char *song = "LeisureSuit:d=16,o=6,b=56:f.5,f#.5,g.5,g#5,32a#5,f5,g#.5,a#.5,32f5,g#5,32a#5,g#5,8c#.,a#5,32c#,a5,a#.5,c#.,32a5,a#5,32c#,d#,8e,c#.,f.,f.,f.,f.,f,32e,d#,8d,a#.5,e,32f,e,32f,c#,d#.,c#"; char *song = "MissionImp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d"; volatile unsigned int time = 0; #define isdigit(n) (n >= '0' && n <= '9') /** Delay function. **/ delay(unsigned int ms) { volatile unsigned int i,ms2; i = time; ms2 = ms*2; while ((time-i) < ms2) { nop(); } } play(unsigned int hz){ CCR0 = (1000000/hz) -1; CCR1 = (1000000/hz)/2; TACTL = TASSEL_2 + MC_1; } stop(){ TACTL = TASSEL_2 + MC_3; //stop CCR0 = 0; } int main(void) { WDTCTL = WDTPW+WDTTMSEL+WDTCNTCL+WDTIS1; // Set interval mode, set to zero and interval to 0.5 ms IE1 |= WDTIE; // Enable WDT interrupt BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; eint(); P1DIR |= BIT2; // P1.2 to output P1DIR |= BIT1; // P1.1 to output P1OUT |= ~BIT1; P1SEL |= BIT2; // P1.2 to TA0.1 CCTL1 = OUTMOD_7; // CCR1 reset/set byte default_dur = 4; byte default_oct = 6; int bpm = 63; int num; long wholenote; long duration; byte note; byte scale; char *p=song; while(*p != ':') p++; // ignore name p++; // skip ':' // get default duration if(*p == 'd') { p++; p++; // skip "d=" num = 0; while(isdigit(*p)) { num = (num * 10) + (*p++ - '0'); } if(num > 0) default_dur = num; p++; // skip comma } // get default octave if(*p == 'o') { p++; p++; // skip "o=" num = *p++ - '0'; if(num >= 3 && num <=7) default_oct = num; p++; // skip comma } // get BPM if(*p == 'b') { p++; p++; // skip "b=" num = 0; while(isdigit(*p)) { num = (num * 10) + (*p++ - '0'); } bpm = num; p++; // skip colon } // BPM usually expresses the number of quarter notes per minute wholenote = (60 * 1000L / bpm) * 4; // this is the time for whole note (in milliseconds) // now begin note loop while(*p) { // first, get note duration, if available num = 0; while(isdigit(*p)) { num = (num * 10) + (*p++ - '0'); } if(num) duration = wholenote / num; else duration = wholenote / default_dur; // we will need to check if we are a dotted note after // now get the note note = 0; switch(*p) { case 'c': note = 1; break; case 'd': note = 3; break; case 'e': note = 5; break; case 'f': note = 6; break; case 'g': note = 8; break; case 'a': note = 10; break; case 'b': note = 12; break; case 'p': default: note = 0; } p++; // now, get optional '#' sharp if(*p == '#') { note++; p++; } // now, get optional '.' dotted note if(*p == '.') { duration += duration/2; p++; } // now, get scale if(isdigit(*p)) { scale = *p - '0'; p++; } else { scale = default_oct; } scale += OCTAVE_OFFSET; if(*p == ',') p++; // skip comma for next note (or we may be at the end) // now play the note if(note) { play(notes[(scale - 4) * 12 + note]); delay(duration); stop(); } else { delay(duration); } } dint(); _BIS_SR(LPM4_bits); } interrupt(WDT_VECTOR) watchdog_timer (void) //__interrupt void watchdog_timer { time++; }
  12. Like
    jsolarski reacted to TheDirty in MSP430F1232   
    The holy grail of sample code:
    http://focus.ti.com/mcu/docs/mcuprodcod ... tabId=1468
     
    Sample code for MSP430F11x2, MSP430F12x, MSP430F12x2:
    http://www.ti.com/lit/zip/slac013
     
    There are several simple ADC examples in it.
  13. Like
    jsolarski reacted to zeke in I stand in want to buy such a cat.   
    Holy CRAP! :shock:
     
    Is this post ever OFF topic!
     
    I propose that this user be punted for being so completely off topic that it's bewilderingly obvious that they are a spammer.
     
    Be gone with ye, Lover of Russian Blue Felines!
     
    This is the only cat we like around here:

  14. Like
    jsolarski reacted to NatureTM in Launchpad Simple MIDI Synth   
    I made a square wave synth that has a standard MIDI interface with launchpad. I think I should make the midi stuff into a library so the code isn't so hard to follow, but clean and polished has never been my thing.
     
    I seem to always have trouble using the USI with serial that doesn't have a clock signal. [E]rr from IRC told me I should use a state machine. I just had sort of a general idea of what that was when I coded it, so I'm not sure "state machine" is the proper term for what I'm using, but I think it's something like that.
     
    Here's the BOM:
    1x TI Launchpad or another MSP430
    1x 280 ohm resistor (can use internal pull-up instead)
    1x 220 ohm resistor
    1x Sharp PC900V optoisolator
    1x Speaker (I just bought one from RadioShack)
    1x MIDI female jack
    A midi cable and some kind of midi controller
     
    ...and the code.
    http://naturetm.com/wp-content/uploads/2011/02/main.c
     
    There's a little more info and some videos of a Launchpad quintet on my blog.
    http://naturetm.com/?p=111
  15. Like
    jsolarski reacted to SugarAddict 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
    jsolarski reacted to RobG in Reading multiple digital inputs   
    It's RobG and it's in addition to what you did, you still have to mask upper bits.

    unsigned int uiPortValue = 0; uiPortValue = P1IN & ( BIT2 | BIT3 | BIT4 |BIT5 ); uiPortValue >>= 2;
     
    Here is another example. Let's say you have P1.0-P1.3 representing 4 data bits D0-D3 and P1.4-P1.7 representing 4 address bits A0-A3

    char data = 0; char addr = 0; data = P1IN & 0x0F; // 0x0F is a mask to hide upper bits and it is equivalent to BIT0 + BIT1 + BIT2 + BIT3 addr = P1IN >> 4;
  17. Like
    jsolarski reacted to cde in Interface 3v MSP430 to 5v Circuits!   
    I know this was mentioned back in the day in the Parallex Sensor thread we had, but I'd figure this is a really useful document (That I just refound and was surprised by) that should be highlighted as this is one of the most common issues.
     
    TI's guide to Interfacing the 3v MSP430 to 5v Circuits.
    Document slaa148
    http://focus.ti.com/lit/an/slaa148/slaa148.pdf
     
    Covers both input and output, and dual direction communication of intervoltage circuits/ics.
     
    A bit dated (Oct 2002) so it doesn't include things like (active or passive) i2c or spi voltage translators but covers most of the useful steps/ideas in a beginner accessible way.
  18. Like
    jsolarski reacted to zeke in Are MSP430 wake up times clock source dependent?   
    If you do happen to use a 32kHz crystal, check out TI's App Note slaa322b.
     
    It goes into detail about how a crystal works, what will make it fail and how to design your circuit for optimal operation.
     
    It's a good one to bookmark.
  19. Like
    jsolarski reacted to OCY in 2 MSP430 sharing one USB UART?   
    I do not see any problem.
    RXD signals for both the MSP430s can be connected together and driven by the USB interface.
    TXD signals from the MSP430s could use serial resistors and then connect together to drive the USB interface. This is to prevent contention despite of the fact that only one of the MSP430s should drive it at any given time (the other one should switch to DIR=0 and ignore the input).
  20. Like
    jsolarski reacted to zeke in Best information for those new to the MSP430?   
    If you are new to the MSP430 then you're probably drowning in information right now.

    It's true that there are a zillion configurations to make before the 430 will do what you want it do do.

    So I'm betting that you are asking yourself "Where do I start?"

    I humbly suggest the following TI application notes and books that will get you going in the right direction:

    1. slaa294: MSP430 Software Coding Techniques

    This application report covers software techniques and topics of interest to all MSP430
    programmers. The first part of the document discusses the MSP430 standard
    interrupt-based code flow model, recommended for the vast majority of applications.
    The next part discusses a handful of techniques that should be considered by any
    developer that sets out to develop an MSP430 application. Using these methods can
    greatly reduce debug time and/or provide additional robustness in the field. They
    include initialization procedures, validation of supply rails before performing
    voltage-sensitive operations, and use of special functions. Code examples are
    provided.

    2. : MSP430 32-kHz Crystal Oscillators

    Selection of the right crystal, correct load circuit, and proper board layout are important
    for a stable crystal oscillator. This application report summarizes crystal oscillator
    function and explains the parameters to select the correct crystal for MSP430
    ultralow-power operation. In addition, hints and examples for correct board layout are
    given. The document also contains detailed information on the possible oscillator tests
    to ensure stable oscillator operation in mass production.

    3. MSP430 Microcontroller Basics by John H. Davies

    The best thing I can say about this book at this time is that it describes well how to make use of the clocking system of the MSP430. This book should be in your personal library or at least on your wishlist.

    Once you digest the information above then you will be in good shape for success in working with the msp430.

    Have something to add?
    Then post up your valuable sources of knowledge.
  21. Like
    jsolarski reacted to Brennan in PWM codes and TimerA   
    I have here some information that might help solve your problem. You can use this as reference about PWM codes and TimerA. I wish you good luck.
     
     
  22. Like
    jsolarski reacted to NatureTM in I bought a logic analyzer   
    Well, I've been using it for a bit now. It's actually pretty useful in several applications I didn't expect. For example, I'm tinkering with an rfid reader. Its baud rate isn't easily divided down to from the default clock settings, so I decided to use something like a state machine to read the data. This involved setting up an interrupt to capture and handle the edge transitions of the serial data.
     
    Well, it wasn't working. I had a suspicion that the interrupt was taking too long, and missing some transitions. In the past, I would have enabled Timer A and used it to count the cycles in the interrupt. Then I'd have to think about if the time would have an impact on operation.
     
    With the logic sniffer, I just added 2 lines to toggle a pin at the beginning of the ISR, and toggled it back at the end. I hooked one lead of the sniffer to the toggled pin, and the other to the serial pin. From there, I was able to see how long the ISR was taking with respect to the serial data rate. I then moved the toggles around within the interrupt to determine which part was the biggest time-waster, and optimized that section. There was less guesswork, and I could get fast visual feedback on how my changes impacted the duration of the ISR.
     
    I guess my point is, It's helped a couple times already, and I think it will help more and more as I figure out new ways to use it.
     
    As far as how well it works... Well, it's pretty buggy, both on the hardware and software sides. It took me some reading and trial and error to figure out which settings play well together. Some settings when used together cause it to fail. Sometimes it just stops working randomly. The solution is just to disconnect it from the computer, reconnect it, and then restart the software.
     
    At first, I was a pretty upset with the bugs. I was starting to think I'd have to make some contributions to the client software just to be able to use it reliably, but I didn't feel like putting another project on my plate. It turns out a lot of the issues are being worked on, and some of the workarounds I was using were documented. Now that I have a feel for what it does and does not like, it's pretty reliable. About 1 in 10 captures fail. Still, I only have to reconnect the device and restart software.
     
    Overall, it's been useful to me, both for debugging and as a learning tool. If you want something that's completely reliable and user-friendly, it might not be a good choice for you, at least in its current state. However If you're like me, operating on a tight budget, willing to spend a little time learning to "play nice" with the system, and willing to deal with a few bugs, I think it's an excellent investment.
  23. Like
    jsolarski reacted to zeke in delay function   
    I tried the for() loops and calls to __delay_cycle(n) but nothing was remotely predictable.
     
    I had to calibrate my g2231 before any sort of delay routine was reliable when the DCO was set to anything other than 1MHz.
     
    The O'scope revealed to me that, once calibrated, the __delay_cycle(n) routine was bang on with every number I threw at it.
     
    Yes, I realize that I'm using CCS4 and not mspgcc but I thought that this info would be useful to someone.
  24. Like
    jsolarski got a reaction from GeekDoc in delay function   
    This Delay function is for mspgcc, this is the one suggested by mspgcc to use instead of
    int i = 1237; while(1--); or
    int i; for (i = 0; i <1234; i++);
    mspgcc will usually remove delays like this thinking it is a wast of space.
     
    mspgcc suggest to use an inline function like this example taken from the mspgcc user guide.

    static void __inline__ msp_delay(register unsigned int n) { __asm__ __volatile__( " 1: \n" " dec %[n] \n" " jne 1b \n" : [n] "+r"(n)); }
    call this function when ever you need to do a short delay(or long one lol)
    example

    //"your code" msp_delay(15); //delay //"your code"
     
    you may be able to use this in CCS or IAR but I'm not sure, since I do not have the windows box to run those programs.
  25. Like
    jsolarski reacted to frozencarbonite in Basic Examples   
    Hi again,
     
    Thought I would share some links I found very helpful as a beginner
     
    I went through this C++ tutorial a while back and it has greatly helped me understand how to code basic programs for a variety of platforms like the arduino, Microsoft Visual C++ and now the MSP430 Launchpad. I think if you are a total newcomer you should start by completing this tutorial:
    http://cplusplus.com/doc/tutorial/
     
    Particularly I keep going to this page as a good reference of what is going on when looking at examples for sometimes the simplest things are not explained:
    http://cplusplus.com/doc/tutorial/operators/
     
    Here is a great explanation of how I/O works on the Launchpad and what got my head out of arduino land:
    http://andrewroycarter.com/?s=msp430
     
    Follow that up with this and memorizing the important bitwise operators:
    http://en.wikipedia.org/wiki/Bitwise_operator
     
    Cde's link seems very promising for newcomers but needs fleshed out especially the analog section:
    http://processors.wiki.ti.com/index.php ... _Community
     
    and then the more advanced projects and blogs
     
    Oh and of course 43oh forum :!: The community here seems very knowledgeable and helpful find what info you need rather than pouring over the fragmented bits of info strewn across the web.
     
    Thanks again
×
×
  • Create New...