Jump to content
43oh

gatesphere

Members
  • Content Count

    430
  • Joined

  • Last visited

  • Days Won

    6

Reputation Activity

  1. Like
    gatesphere reacted to Fe2o3Fish in Special TI eStore offers for Facebook critters   
    FYI, FWIW, IYGARA -- This just popped up on my Facebook feed:
     
    Interested in TI Microcontroller development tools? You
  2. Like
    gatesphere reacted to NatureTM in Arduino for the launchpad   
    I've got a couple snippets that are similar to arduino functions. I just assumed this stuff was already out there.
     
    Here's what I have for millis and delayMillis:
     

    #include "msp430g2231.h" #define MCLK_FREQUENCY 1000000 #define WDT_DIVIDER 512 const unsigned long WDT_FREQUENCY = MCLK_FREQUENCY / WDT_DIVIDER; volatile unsigned long wdtCounter = 0; unsigned long millis(){ return wdtCounter / ((float)WDT_FREQUENCY / 1000); } void delayMillis(unsigned long milliseconds){ // todo: handle rollover unsigned long wakeTime = wdtCounter + (milliseconds * WDT_FREQUENCY / 1000); while(wdtCounter < wakeTime); } void main(void){ DCOCTL = CALDCO_1MHZ; BCSCTL1 = CALBC1_1MHZ; WDTCTL = WDTPW + WDTTMSEL + WDTIS1; IE1 |= WDTIE; _BIS_SR(GIE); // toggle pin every second P1DIR |= BIT0; while(1){ P1OUT ^= BIT0; delayMillis(1000); } } #pragma vector=WDT_VECTOR __interrupt void watchdog_timer(void){ wdtCounter++; }
     
    And here's what I have for analogRead:
     

    #include "msp430g2231.h" #define ANALOG_PIN 4 unsigned int analogRead(){ ADC10CTL0 |= ADC10SC; while(ADC10CTL1 & ADC10BUSY); return ADC10MEM; } void analogPinSelect(unsigned int pin){ if(pin < 8){ ADC10CTL0 &= ~ENC; ADC10CTL1 = pin << 12; ADC10CTL0 = ADC10ON + ENC + ADC10SHT_0; } } void main(void){ unsigned int analogValue; DCOCTL = CALDCO_1MHZ; BCSCTL1 = CALBC1_1MHZ; WDTCTL = WDTPW + WDTHOLD; // read adc repeatedly analogPinSelect(ANALOG_PIN); while(1){ analogValue = analogRead(); } }
  3. Like
    gatesphere reacted to zeke in Best information for those new to the MSP430?   
    So, now you got a job doing hardware design and you want to use the MSP430 in your design.
     
    But you've discovered that your boss has insisted on using this "wicked cool awesome" and ancient 5V sensor because they have a bazillion in stock.
     
    "What's the problem with that?" you ask.
     
    The problem is this: the MSP430 is a 3.6V device and it doesn't have 5V tolerant I/O's. This means that you'll probably hurt the part if you put 5V into an input. Go ahead and google it. You'll find our very own OCY schooling someone on this topic back in 2008. I'll let you find the article. OCY is shy. And he's probably gonna rip me open for giving away his secret identity.
     
    So, what's the answer? SLAA148 is the answer.
     
    It will take you through the various input and output scenarios that you may face trying to interface to higher voltage systems - not just 5V.
     
    Using this information, you should be able to measure the status of a 12V power supply with the A/D inputs or figure out how to drive a 12V relay.
     
    Have a read. It's useful info.
  4. Like
    gatesphere reacted to zeke in Best information for those new to the MSP430?   
    As you progress in your development of an embedded system based upon the MSP430, you will eventually have to cut your dependency on your dev board. When you do this, you will have to give your system the ability to be programmed.
     
    Whether by JTAG or by Spy-Bi-Wire, you will have to assimilate and understand the information inside this document. Otherwise, you will have a brick coming off the assembly line.
     
    Do want to make a million bricks or a million dollars?
     
    Knowing this information will save you time, money and prevent ulcers!
     
     
    4. slau320: Programming via the JTAG Interface
     
    This document describes the functions that are required to erase, program, and verify the memory module
    of the MSP430
  5. Like
    gatesphere 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.
  6. Like
    gatesphere reacted to zeke in CNX.org has MSP430 training materials online   
    I was smurfing the web tonight and stumbled across this webpage at CNX.org:
     
    Teaching and classroom laboratories based on the
  7. Like
    gatesphere reacted to bluehash in Evalbot Expansion ports   
    http://www.samtec.com/ProductInformatio ... series=SFM
  8. Like
    gatesphere reacted to JMLB in Arduino for the launchpad   
    I saw this on Hack a day in case some of you don't read it
    https://github.com/chrishulbert/friendly_launchpad
  9. Like
    gatesphere reacted to NatureTM in Parallax RFID reader   
    I saw touch ported some rfid reader code to msp430, and so I thought I'd share what I've got for the Parallax RFID reader. The code is a bit bloated and inefficient, but it seems to work well. It compiles from about 1300B to 1500B program size in CCS, depending on if optimization is used, and uses 60B RAM.
     
    Most of the work is done in software, so TimerA and the USI are free. I couldn't get it to run at 1MHz, so you'll need an MSP430 with calibration constants or a clock source. It works fine at 8MHz or higher.
     
    I used a voltage divider to bring the reader's 5V data line down, and powered the reader with my launchpad's TP1 and TP4 test points.
     

    #include "msp430g2231.h" #include #define PIN_RFID_DATA BIT7 // normally high #define PIN_RFID_ENABLE BIT4 // active LOW #define PIN_LED BIT0 #define RFID_BAUD 2400 #define MCLK_FREQUENCY 8000000 #define WDT_DIVIDER 512 #define BYTES_PER_MESSAGE 12 #define BYTES_PER_TAG 10 #define N_ALLOWED_TAGS 1 #define RESULT_SUCCESS 0 #define RESULT_TIMEOUT 1 #define RESULT_ERROR 2 #define RESULT_NO_DATA 3 #define READER_WARMUP 800 #define MIDSCAN_TIMEOUT 200 const char tags[N_ALLOWED_TAGS][bYTES_PER_TAG] = {'3', '6', '0', '0', '6', '2', '2', 'B', 'A', 'E'}; const unsigned long WDT_FREQUENCY = MCLK_FREQUENCY / WDT_DIVIDER; volatile unsigned long wdtCounter = 0; unsigned int stateCount; char rfidData[bYTES_PER_MESSAGE] = {0}; char rfidByte; char bitIndex = 0; char newByte = 0; volatile char haveNewByte = false; volatile char busy = false; char wdtTicksPerBit; unsigned long millis(){ return wdtCounter / ((float)WDT_FREQUENCY / 1000); } void delayMillis(unsigned long milliseconds){ unsigned long wakeTime = wdtCounter + (milliseconds * WDT_FREQUENCY / 1000); while(wdtCounter < wakeTime); } void addBits(char n, char state){ int i; if(state) for(i = 0; i < n; i++){ rfidByte |= 0x01 << bitIndex; bitIndex++; } else for(i = 0; i < n; i++){ rfidByte &= ~(0x01 << bitIndex); bitIndex++; } } char scanTag(){ unsigned long timeout = millis() + READER_WARMUP; char byteIndex = 0; P1OUT &= ~PIN_RFID_ENABLE; while(!haveNewByte){ if(millis() > timeout){ P1OUT |= PIN_RFID_ENABLE; busy = false; return RESULT_NO_DATA; } } if(newByte == 0x0A){ while(byteIndex < BYTES_PER_MESSAGE){ timeout = millis() + MIDSCAN_TIMEOUT; rfidData[byteIndex] = newByte; byteIndex++; haveNewByte = false; while(!haveNewByte){ if(millis() > timeout){ P1OUT |= PIN_RFID_ENABLE; busy = false; return RESULT_TIMEOUT; } } } P1OUT |= PIN_RFID_ENABLE; return RESULT_SUCCESS; } else{ P1OUT |= PIN_RFID_ENABLE; haveNewByte = false; busy = false; return RESULT_ERROR; } } char isValidTag(){ char iTag; char iByte; char valid = true; for(iTag = 0; iTag < N_ALLOWED_TAGS; iTag++){ for(iByte = 0; iByte < BYTES_PER_TAG & valid; iByte++){ if(rfidData[iByte + 1] != tags[iTag][iByte]) valid = false; } } return valid; } void handleMessage(){ if(isValidTag()) P1OUT ^= PIN_LED; } void main(void){ DCOCTL = CALDCO_8MHZ; BCSCTL1 = CALBC1_8MHZ; WDTCTL = WDTPW + WDTTMSEL + WDTIS1;// + WDTIS0; IE1 |= WDTIE; // Enable WDT interrupt wdtTicksPerBit = ((float)WDT_FREQUENCY / RFID_BAUD); P1IE |= PIN_RFID_DATA; P1IES |= PIN_RFID_DATA; P1DIR |= PIN_RFID_ENABLE + PIN_LED; P1OUT |= PIN_RFID_ENABLE + PIN_LED; _BIS_SR(GIE); // enable interrupts while(1){ switch(scanTag()){ case RESULT_SUCCESS: handleMessage(); delayMillis(1000); break; case RESULT_NO_DATA: delayMillis(1000); break; // nothing here for RESULT_ERROR // just scan the tag again right away } } } #pragma vector=WDT_VECTOR __interrupt void watchdog_timer(void){ stateCount++; wdtCounter++; } #pragma vector=PORT1_VECTOR __interrupt void Port1(void){ static char state; unsigned int nBits; P1IES ^= PIN_RFID_DATA; // capture both edges P1IFG &= ~PIN_RFID_DATA; if(!busy){ bitIndex = 0; busy = true; state = 0; stateCount = wdtTicksPerBit * -1; // ignore start bit } else{ nBits = (stateCount / wdtTicksPerBit); // trim off the stop bit if the last data bit is also a "1" // maybe catch some other unexpected behavior too if(nBits + bitIndex > 8) nBits = 8 - bitIndex; addBits(nBits, state); state ^= BIT0; stateCount = 0; } if(bitIndex == 8){ busy = false; newByte = rfidByte; haveNewByte = true; } }
     
    This was part of a project I was working on to tweet when my cats poop. I was using some RF Link boards from eBay so I wouldn't need a data connection to the litter box. It turns out RF Links are very noisy, and the code for wireless was just too big for my 2K flash MSP430's. I've got some 8K's on order, but for now my cats' bowel movements will continue to remain a mystery.
  10. Like
    gatesphere got a reaction from GeekDoc in Found a site with a lot of EE/CS books, looks legit   
    Hey all
     
    Found a site with a lot of EE/CS books. The links (for the most part) are legit. Might be worth looking into.
     
    http://www.sciencebooksonline.info/engi ... ronic.html
  11. Like
    gatesphere reacted to Mac in 2x16 HD44780, White on Blue, $3.49 (incl shpg)   
    A chap on another forum bought a few of these displays from the Hong Kong vendor and he says they're pretty nice. I thought it was a pretty good price and so I thought you guys wouldn't mind me passing along the link to the vendor.
     
    Cheerful regards, Mike McLaren, K8LH
     

  12. Like
    gatesphere got a reaction from bluehash in Found a site with a lot of EE/CS books, looks legit   
    Hey all
     
    Found a site with a lot of EE/CS books. The links (for the most part) are legit. Might be worth looking into.
     
    http://www.sciencebooksonline.info/engi ... ronic.html
  13. Like
    gatesphere got a reaction from RobG in Found a site with a lot of EE/CS books, looks legit   
    Hey all
     
    Found a site with a lot of EE/CS books. The links (for the most part) are legit. Might be worth looking into.
     
    http://www.sciencebooksonline.info/engi ... ronic.html
  14. Like
    gatesphere reacted to RobG in Saving data to flash on power down   
    Here is a simple solution to the problem I had, saving data when power goes down.
    There are two parts needed, a diode (1N4148) and a capacitor (~47uF.)
    The way it works, you isolate main power from MCU and connect capacitor on the MCU's side.
    One of the pins is connected to the main power and will trigger an interrupt.
    In the interrupt routine, we will be saving data to flash.
    This is a simple proof of concept, the final code should include low voltage detection for situations like dying battery.
     

     


     

    #include "msp430g2231.h" unsigned int data = 0; unsigned int * const savedDataPtr = (unsigned int *)(0x1000); void main(void) { WDTCTL = WDTPW + WDTHOLD; P1DIR &= ~BIT1; P1IE |= BIT1; P1IES |= BIT1; P1IFG &= ~BIT1; P1REN |= BIT1; P1OUT &= ~BIT1; P1DIR |= BIT0; P1OUT |= BIT0; data = *savedDataPtr; if(data == 0xFFFF) data = 100; unsigned int counter = data; _bis_SR_register(GIE); while(1) { counter = data; while(counter > 0) { _delay_cycles(1000); counter--; } P1OUT ^= BIT0; } } // Port 1 interrupt service routine #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { P1OUT &= ~BIT0; data += 100; // Save value FCTL2 = FWKEY + FSSEL0 + FN1; FCTL1 = FWKEY + ERASE; FCTL3 = FWKEY; *savedDataPtr = 0; FCTL1 = FWKEY + WRT; *savedDataPtr = data; FCTL1 = FWKEY; FCTL3 = FWKEY + LOCK; P1IFG &= ~BIT1; }
  15. Like
    gatesphere reacted to infrared in f5522 shows up in Motorola Atrix MultiMedia Docks   
    The Motorola Atrix 4G is the worlds first dual core smartphone running Android OS. The uniqueness of the Atrix is the Docks that can be purchased as accessories. There is a multimedia dock that has an infrared remote control, 3 USB ports and connects to the display via a pass through HDMI cable. The phone has a Ubuntu "webtop" application that starts when plugged into the dock. (there is even a really cool laptop dock that turns the phone into a full laptop)
     
    @BlueHash I did not tear one down to find out. A dev @ http://forum.xda-developers.com/showthread.php?t=963938&page=9 specifically this post http://forum.xda-developers.com/showpost.php?p=11658048&postcount=84 tore one down and posted about the IC's inside.
     
    Now, I am not going to pay $200 for a dock that has a <$5 TI msp430 in it. So I am building my own with a launchpad. Over at XDA they are trying to get it to work without a dock at all and just an HDMI cable, using scripts and modified config files.
     
    I have it working in webtop mode with a modified USB hub. The issue is sending an ID to the Atrix (f5522 must be doing this) to determine the dock type connected to and launching the appropriate application. (for example the car dock differs by not having HDMI so webtop does not get launched, instead the car dock launches a UI specific for operating a car i.e. Nav and music streaming.)
     
    Unfortunately, Motorola axed the capability to use the applications without a dock being attached.
    I assume the f5522 is handling the host mode/peripheral mode of the Atrix USB port so that a mouse/keyboard can be wired (although bluetooth is the recommended way of attaching HID).
     
    With the f5522 firmware, I may be able to design my own dock capable of new things. Need to know how the ID pin is pulled low and when the SID is sent to the phone.
  16. Like
    gatesphere 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; }
  17. Like
    gatesphere 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().
  18. Like
    gatesphere reacted to zeke in Using 3 wires to control parallel LCD display   
    Sorry for hijacking the topic...
     
    Mac, you're going to have to do a screencast of you making a drawing.
     
    I have to see this with my own eyes.
  19. Like
    gatesphere reacted to ZeroSkillz in n00b tutorial - AND; OR and NOT   
    I'm a total n00b, and from what I have seen, there are a lot of us here so I figured I'd share what I've been learning and maybe help some others along the way! While running demos and looking at the code that makes them tick you will come across things like this:
     
    P1OUT |= BIT6
    P1OUT &= ~BIT6
     
    And to a n00b this looks like gibberish! Lets break it down and learn! - as taught to me by my mentor & friend Sven (Thanks bub!).
     
    There are three basic functions in play here AND; OR and NOT. Lets start with NOT.
     
    1101 1010 <- binary representation of a byte (8bits)
     
    What NOT does is INVERT the bits:
     
    NOT
    1101 1010
    0010 0101 <- RESULT
     
    What was ON is now OFF (and vice versa)
     
    Now, lets look at OR. While NOT operates on ONE value, OR (as well as AND) operate on TWO values and combines them in a way to create a result. OR sets all the bits that are in either (a) OR (.
     
    1100 0000 (a)
    OR
    0001 0001 (
     
    1101 0001 <- RESULT
     
    Another example:
    1100 001 (a)
    OR
    1101 000 (
     
    1101 001 <- RESULT (same as the first result)
     
    If a bit at a certain position is set to 1 in either the first (a) OR the second ( var, the bit in the result will be set to 1 also.
     
    Now, lets look at AND. The difference between OR and AND is that the bit in the result will be set only if BOTH the first (a) and the second ( var are set.
     
    1100 0001 (a)
    AND
    1000 0100 (
     
    1000 0000 <-RESULT
     
    Only the topmost bit (BIT7) is set in (a) AND (, so only the topmost bit is set in the result.
     
    SO - NOW WHAT!? well, in C we don't write OR, AND and NOT...we use symbols.
     
    & is AND
    | is OR
    ~ is NOT
     
    Lets look at a line of code:
     
    P1OUT =P1OUT &~BIT6
     
    What this line of code does is MASK bit number 6. It takes what is currently in P1OUT then does an AND with EVERYTHING except BIT6 and writes it back to P1OUT. Whatever was written to P1OUT still be there EXCEPT for BIT6, which will be set to zero. We can make this line shorter:
     
    P1OUT &= ~BIT6
     
    On a LaunchPad it turns off the Green LED located at 1.6 - ISN'T THAT GREAT TO KNOW!?
     
    When you want to change a bit in a port, you CANNOT access just that one bit. You can only write a WHOLE byte to memory, which effects all 8 port bits. So, since you do not want to change the other bits you need to read the current state, leaving all the other bits unchanged by using AND with ALL bits except the one you want to clear (BIT6).
     
    Lets say that P1OUT looks like this:
     
    1101 0001
     
    BIT0, BIT4, BIT6 and BIT7 are set (Zero is rightmost Seven is topmost). Now you create your mask by doing a NOT on a single BIT (BIT6). BIT6 Looks like this:
     
    0100 0000
     
    NOT BIT6 (~BIT6) Looks like this:
     
    1011 1111
     
    Now, if you do an AND operation with this MASK all bits will remain unchanged except BIT6 which will always result in zero. You write the result back to the port byte and you have only affected ONE bit (BIT6) while all the others remain the unchanged.
     
    SO - HOW DO I TURN BIT6 ON!?
     
    You just OR the port with the desired bit:
     
    P1OUT |= BIT6
     
    If BIT6 is already set, there is no change. If BIT6 was not set it is now. On a Launchpad the green LED would turn ON or STAY ON.
     
    Just for fun:
     
    P1OUT &= ~(BIT6|BIT0)
     
    This line of code will turn OFF BOTH LED's on a Launchpad.
     
    Happy coding!
    ZeroSkillz
  20. Like
    gatesphere 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
  21. Like
    gatesphere reacted to bluehash in Boards updated to the latest PHPBB3 3.0.8 version   
    Everything went smoothly. We had to restrict the boards for one hour, sorry to those who got kicked out.
    If you notice anything gone wrong, please PM or contact us. Thanks!
     
    Release notes if anyone is interested.
  22. Like
    gatesphere 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++; }
  23. Like
    gatesphere reacted to GeekDoc in Nicer code formatting?   
    There's what looks like a nice code formatting mod (a bit old, but should still work) here:
    http://www.phpbb.com/community/viewtopi ... 0&t=564569
     
    Another here:
    http://www.zerozaku.com/viewtopic.php?f=66&t=4972
     
    I'm sure there are more, but I think displaying code as something better than green text would be nice.
  24. Like
    gatesphere reacted to ech0s in Eval bot documentation and herdles   
    http://ti-evalbot.proboards.com/index.c ... &thread=26
     
    plus included examples and unxutils for make on windows
  25. Like
    gatesphere 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.
×
×
  • Create New...