Jump to content


  • Content Count

  • Joined

  • Last visited

Reputation Activity

  1. Like
    russcky reacted to zeke in External power supply on MSP430F5529-LP boosterpack connector?   
    I have the same version of LP board as you (V1.4).
    You have to pull the SBWRST and SBWTST jumpers as well or else it will not work because the MSP will be held in reset by the unpowered eZ-FET lite circuitry.
    Just pull out all of those jumpers then apply 3V to the board at either at J10:3(3V3) or at J1:1(3V3).
    Here is the LP schematic for reference. It's V1.5 but it will work for this conversation.
  2. Like
    russcky reacted to RobG in [Energia Library] Nokia 5110 LCD BoosterPack/Breakout PCB   
    @@russcky, there are few other (non-Energia) libraries floating around here and I remember we did have a discussion about images on 5110 at some point, just can't locate it.
  3. Like
    russcky reacted to calinp in [Energia Library] Petit FatFS SD Card Library   
    Hi russcky,
    The Petit FatFS library does not support multiple files open. You can find more information on http://elm-chan.org/fsw/ff/00index_p.html .
    Searching with lseek works, but is very slow to do this multiple times.
    This library supports a forwarding function that I did not implement (check the examples from the link for an implementation).
  4. Like
    russcky reacted to Rickta59 in Petit FatFs sound player   
    I've been experimenting with playing sound. I'm using the code below to read raw 8bit unsigned PCM files
    from the SDCard booster pack. I've attached the main routine. It is heavily commented so I'm not going
    to say much more than here it is. The Petit Fat Filesystem code can be found on the documents tab
    of the SDCard booster on the 43oh.com store.
    I also want to thank oPossum and woodgrainn with their help creating a decent low pass RC filter. I ended up
    using an LM386 as an amplifier on the P1.2 PWM output. Here is the schematic for that:

    /* * pcmplayer.cpp - play a 15.625kHz 8bit mono sound file using PWM. * * This snippet plays raw PCM audio files from an SDcard. It looks * for files named 0.raw, 1.raw ... 9.raw and attempts to play them * in a loop. To create these files, use the Audacity program to * sample sound files, convert stereo to mono, then export them * as 8bit unsigned data 15625Hz without a header. * * The SDcard I/O is handled using Petit FatFs and works with both FAT16 * and FAT32 formatted cards. PetitFS has a streaming read feature which * allows you process each byte from the file without buffering using * its callback feature. * * * Inspired from various sources: * * http://www.arduino.cc/playground/Code/PCMAudio * http://elm-chan.org/fsw/ff/00index_p.html * http://en.wikipedia.org/wiki/Pulse-code_modulation * http://en.wikipedia.org/wiki/Pulse-width_modulation * http://en.wikipedia.org/wiki/Low-pass_filter * http://sim.okawa-denshi.jp/en/CRtool.php * http://www.ti.com/lit/an/slaa497/slaa497.pdf * http://www.proaxis.com/~wagnerj/PWMfil/PWM%20Filters.pdf * * help on low pass filtering from oPossum and woodgrainn * * 3920 bytes on a msp430g2553 with msp430-gcc 4.6.3 -Os */ /** * pins used on msp430g2553 * * +-- --+ * | V | * | | * P1.2 TA0.1<<< | * | | * | | * | >>>> MOSI P1.7 * P1.5 SCK <<<< <<<< MISO P1.6 * P2.0 CS <<<< | * | | * | | * +-----+ * * P1.2 - PWM output, run through a low pass RC filter. I'm using * a 470ohm resistor, and 100nF cap played back on cheap airline * headphones. Don't use these values with PC audio card mic or * line in. * * P1.5, P1.6, P1.7 SCLK, MISO, MOSI (USCI SPI) connect to SD card * P2.0 CS connect to SD card * */ #include #include extern "C" { #include "spi.h" #include "diskio.h" #include "pff.h" } #include "mmc.h" #include "ringbuffer.h" static const uint32_t TIMERA_CLK = 16000000; // SMCLK_FREQ/1 static const uint32_t SAMPLE_RATE = 15625; // nice power of 2 friendly value sample rate RingBuffer sample_buffer = {{0}, 0,0}; // structure to buffer our samples /* * on_streaming_data() - called when pf_read completes a read * * pf_read in streaming mode calls this function after each byte * is read. When we get a new value we stuff it into a ring buffer. * The ISR reads from this ring_buffer. This function is the * producer, the ISR is the consumer. */ void on_streaming_data(uint8_t sample) { register int16_t rc, scaled_sample; scaled_sample = sample < 24 ? 24 : sample; // avoid low range glitches scaled_sample <<= 2; // scale it up from 0-255 to 0-1023 do { /* * stuff this at the end of our circular queue * if rc == -1 then it would overflow, wait for * ISR to read a byte */ rc = sample_buffer.push_back(scaled_sample); } while (rc == -1); } /** * Timer0 CCR0 overflow handler * * This method is called each time the CCR0 value counts up to 1023. * We grab the next sample from the circular buffer and scale it * up from the 8 bit unsigned value read from the disk to match * the CCR0 scale. */ #pragma vector = TIMER0_A0_VECTOR void __interrupt TIMER0_OVERFLOW_VECTOR_ISR(void) { // P1OUT ^= BIT0; TACCR1 = sample_buffer.pop_front(); // P1OUT ^= BIT0; } int main(void) { FRESULT res; // PetitFS variables DRESULT dres; FATFS fs; WDTCTL = WDTPW + WDTHOLD; // Stop WDT DCOCTL = 0; // Run at 16 MHz BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; //DCOCTL += 3; // fine tune 15.9MHz to 16.0MHz on my chip __delay_cycles(0xffff); // delay for power up and stabilization spi_initialize(); // configure SPI for Petit FatFs 8MHz // P1OUT &= ~BIT0; P1DIR |= BIT2 /*| BIT0*/; // P1.2 output P1SEL |= BIT2; // P1.2 use TA0.1 //P1DIR |= BIT4; P1SEL |= BIT4; // output SMCLK, useful for measuring /** * configure TimerA0 with a 15.625k frequency, * setup TA0.1 (P1.2) for the PWM output. */ TACCR0 = (TIMERA_CLK/SAMPLE_RATE)-1; // PWM Period 15.625k (64 us) TACCR1 = TACCR0/2; // Set initial PWM duty cycle to 50% TACCTL0 = CCIE; // Enable CCRO CCIFG interrupt. The TACCR0 CCIFG // interrupt flag is set when the timer counts to // the TACCR0 value. TACCTL1 = OUTMOD_7; // Output is reset (0) when timer counts // to TACCR1, It is set (1) when timer counts // to TACCR0 value TACTL = TASSEL_2 | ID_0 | MC_1; // use SMCLK / 1, in UP MODE to CCR0 // value 1024-1 cycles((16MHz/1)/15.625kHz) __enable_interrupt(); /** * play the same songs in a loop */ while(1) { dres = disk_initialize(); if ( dres == RES_OK ) { res = pf_mount(&fs); if ( res == FR_OK ) { int n; char fileName[] = "0.raw"; for ( n=0; n < 10; n++ ) { fileName[0] = n+'0'; res = pf_open(fileName); if ( res == FR_OK ) { WORD bytes_read; do { res = pf_read(0, 32768, &bytes_read); /* pf_read calls on_streaming_data() for each byte read */ if (res != FR_OK) { break; } } while (bytes_read == 32768); /* read a cluster at a time */ } } } } } return 0; }
  5. Like
    russcky got a reaction from sirri in [Energia Library] Petit FatFS SD Card Library   
    @@sirri, I only have 2 SD cards I have handy to test are 2GB or smaller.  
    I'll see if I can locate any larger and test but a quick check tonight hasn't turned up any.
  6. Like
    russcky got a reaction from sirri in [Energia Library] Petit FatFS SD Card Library   
    Hi @@rotbeer and @@sirri,
    I was trying to use P2.2 for chip select CS but noticed the change in the library and now use  P1.4.
    #define cs_pin      6     // P1.4
    myerr = FatFs.begin(cs_pin,3); // initialize FatFS library calls
    I think this was my problem.
  7. Like
    russcky reacted to semicolo in Yet another music box simulator   
    I made a more in depth description of the project using the hackster.io site:
  8. Like
    russcky reacted to NatureTM in Music with only a speaker, a LP, and 30 lines of code   
    Hi everyone, it's been awhile.
    I just wanted to share something interesting lasershark mentioned on my blog awhile ago.  It's basically a way to make music with one line of code.  It took about 15 minutes to implement on a g2553 and only requires a launchpad and a speaker.  I found it pretty entertaining.  Just connect one terminal of the speaker to Port 1.2 and the other to ground, or drive it with a transistor.
    Original project @ http://canonical.org/~kragen/bytebeat/
    #include "msp430g2553.h" #define MCLK 8000000 #define OUTPUT_SAMPLES_PER_SECOND 8000 #define PIN_SPEAKER BIT2 unsigned long t = 0; unsigned char sample; void main(void) { WDTCTL = WDTPW + WDTHOLD; DCOCTL = CALDCO_8MHZ; BCSCTL1 = CALBC1_8MHZ; P1SEL |= PIN_SPEAKER; P1DIR |= PIN_SPEAKER; TA0CTL = TASSEL_2 | MC_1; TA0CCR0 = (0x0001 << 8) - 1; TA0CCTL1 |= OUTMOD_7; TA1CTL = TASSEL_2 | MC_1; TA1CCR0 = MCLK / OUTPUT_SAMPLES_PER_SECOND - 1; TA1CCTL0 |= CCIE; _enable_interrupts(); while(1){ sample = ((t<<1)^((t<<1)+(t>>7)&t>>12))|t>>(4-(1^7&(t>>19)))|t>>7; // sample = t*(((t>>12)|(t>>8))&(63&(t>>4))); // sample = (t*(t>>5|t>>8))>>(t>>16); // sample = t*(((t>>9)|(t>>13))&(25&(t>>6))); // sample = t*(((t>>11)&(t>>8))&(123&(t>>3))); // sample = (t*5&t>>7)|(t*3&t>>10); // sample = (t&t%255)-(t*3&t>>13&t>>6); // sample = t>>4|t&((t>>5)/(t>>7-(t>>15)&-t>>7-(t>>15))); // sample = (t*9&t>>4|t*5&t>>7|t*3&t/1024)-1; // sample = ((t*(t>>12)&(201*t/100)&(199*t/100))&(t*(t>>14)&(t*301/100)&(t*399/100)))+((t*(t>>16)&(t*202/100)&(t*198/100))-(t*(t>>17)&(t*302/100)&(t*298/100))); // sample = t*(t^t+(t>>15|1)^(t-1280^t)>>10); // sample = t&t>>8; //44 khz // sample = ((t/2*(15&(0x234568a0>>(t>>8&28))))|t/2>>(t>>11)^t>>12)+(t/16&t&24); // sample = ((t*("36364689"[t>>13&7]&15))/12&128)+(((((t>>12)^(t>>12)-2)%11*t)/4|t>>13)&127); t++; LPM0; } } #pragma vector = TIMER1_A0_VECTOR __interrupt void T1A0_ISR(void) { TA0CCR1 = sample; LPM0_EXIT; }  
    Switch which "sample =" line is uncommented to change the "song."  The songs are from http://pelulamu.net/countercomplex/music_formula_collection.txt and there are more in that file.
  9. Like
    russcky reacted to Rickta59 in Problem with interrupts on P1 and a timer   
    Here is a follow up to the original post that is focused on trying to use the framework and stay in LPM4 as much as possible
    File: LPM_Button.ino

    /** * LPM_Button - simple button handler with sleep features * * Demonstrates how to sleep in LPM4 and have port interrupt wake up on button push, * switch to LPM3 run for a bit and then go back to LPM4 from interrupts. */ typedef unsigned int (*uintFuncPtr)(void); /* forward declarations */ void attachInterrupt2(uint8_t, uintFuncPtr, int); unsigned int handleButton(void); /* * -- G L O B A L V A R I A B L E S -- */ unsigned char count = 0; volatile unsigned char times = 0; /* * setup() - Configure pins, disable WDT, assign Pushbutton (p1.3) interrupt handler */ void setup() { disableWatchDog(); // disable timer keeper to use less power pinMode(RED_LED,OUTPUT); pinMode(GREEN_LED,OUTPUT); pinMode(PUSH2, INPUT_PULLUP); digitalWrite(RED_LED, HIGH); digitalWrite(GREEN_LED, LOW); attachInterrupt2(PUSH2, handleButton, RISING); } void loop() { LPM4; // start in ultra low power mode, all work is done in the ISR routines } /* * handleButton() - interrupt handler for button up (low -> high) event */ unsigned int handleButton(void) { ++times; P1OUT |= digital_pin_to_bit_mask[RED_LED]; P1OUT &= ~digital_pin_to_bit_mask[GREEN_LED]; // Set up Timer A "Up to CCR0" mode, divide by 2^n, clock from SMCLK (2)/ACLK (1), clear timer TACCR0 = 0x1fff; TACCTL0 = CCIE; TACTL = MC_1 | ID_0 | TASSEL_1 | TACLR; return OSCOFF; // switch from LPM4 to LPM3 so the ACLK can drive the Timer clock } /* * TA0_ISR() - Handle CCR0 interrupt * in LPM3 mode, blink the lights and then go back to deep sleep */ __attribute__((interrupt(TIMER0_A0_VECTOR))) static void TA0_ISR(void) { if (++count > 2 * times) { P1OUT |= digital_pin_to_bit_mask[RED_LED]; P1OUT &= ~digital_pin_to_bit_mask[GREEN_LED]; TACTL = TACLR; __bis_status_register_on_exit(OSCOFF); // switch back back into LPM4 sleep } else { P1OUT ^= digital_pin_to_bit_mask[RED_LED]|digital_pin_to_bit_mask[GREEN_LED]; } }
    File: WInterrupt2.ino

    /* * WInterrupt2.ino - interrupt handlers with LPM modification * * Functions that provide a way for user written PORTN interrupt handlers to clear bits * in the SR register of an ISR so the MCU can switch sleep modes. The user written * handlers should return 0 or an unsigned LPM modebit value(s) to clear on ISR exit. * * Based on WInterrupts.cpp * * Author: Rick Kimball <rick@kimballsoftware.com> */ #define bit_pos(A) ((A) == 1u << 0 ? 0 \ : (A) == 1u << 1 ? 1 \ : (A) == 1u << 2 ? 2 \ : (A) == 1u << 3 ? 3 \ : (A) == 1u << 4 ? 4 \ : (A) == 1u << 5 ? 5 \ : (A) == 1u << 6 ? 6 \ : (A) == 1u << 7 ? 7 \ : 0) typedef unsigned int (*uintFuncPtr)(void); #define NUM_INTS_PER_PORT 8 static volatile uintFuncPtr intFuncP1[NUM_INTS_PER_PORT]; #if defined(__MSP430_HAS_PORT2_R__) static volatile uintFuncPtr intFuncP2[NUM_INTS_PER_PORT]; #endif /** * attachInterrupt2 - assign a user defined function to a port interrupt pin */ void attachInterrupt2(uint8_t interruptNum, unsigned int (*userFunc)(void), int mode) { uint8_t bit = digitalPinToBitMask(interruptNum); uint8_t port = digitalPinToPort(interruptNum); if ((port == NOT_A_PIN) || !((mode == FALLING) || (mode == RISING))) return; __dint(); switch(port) { case P1: P1IE |= bit; P1IFG &= ~bit; P1IES = mode ? P1IES | bit : P1IES & ~bit; intFuncP1[bit_pos(bit)] = userFunc; break; #if defined(__MSP430_HAS_PORT2_R__) case P2: P2IE |= bit; P2IFG &= bit; P2IES = mode ? P2IES | bit : P2IES & ~bit; intFuncP2[bit_pos(bit)] = userFunc; break; #endif default: break; } __eint(); } void detachInterrupt2(uint8_t interruptNum) { uint8_t bit = digitalPinToBitMask(interruptNum); uint8_t port = digitalPinToPort(interruptNum); if (port == NOT_A_PIN) return; switch(port) { case P1: P1IE &= ~bit; intFuncP1[bit_pos(bit)] = 0; break; #if defined(__MSP430_HAS_PORT2_R__) case P2: P2IE &= ~bit; intFuncP2[bit_pos(bit)] = 0; break; #endif default: break; } } __attribute__((interrupt(PORT1_VECTOR))) void Port_1(void) { uint8_t i; for(i = 0; i < 8; i++) { if((P1IFG & BV(i)) && intFuncP1[i]) { unsigned bits2clear; if ( bits2clear=intFuncP1[i]() ) { __bic_status_register_on_exit(bits2clear); } P1IFG &= ~BV(i); } } } #if defined(__MSP430_HAS_PORT2_R__) __attribute__((interrupt(PORT2_VECTOR))) void Port_2(void) { uint8_t i; for(i = 0; i < 8; i++) { if((P2IFG & BV(i)) && intFuncP2[i]) { unsigned bits2clear; if ( bits2clear=intFuncP2[i]() ) { __bic_status_register_on_exit(bits2clear); } P2IFG &= ~BV(i); } } } #endif
  10. Like
    russcky reacted to cde in [Energia Library] Nokia 5110 LCD BoosterPack/Breakout PCB   
    I'm no c++ expert (or user or fan) but the library is built using constructors. You can use the default values, or you can use your own values. The only unique pin would be the Chip-Select.
    Instead of just initializing it as "LCD_5110 myScreen;" you would need
    LCD_5110 screenOne; LCD_5110 screenTwo(Another Free Pin,    // Chip Select              P2_4,    // Serial Clock              P2_0,    // Serial Data              P2_3,    // Data/Command              P1_0,    // Reset              P2_1,    // Backlight              PUSH2);   // Push Button 2 Or Different) That's for the software SPI with default pins for the g2553. Each screen would be individually controlled with screenOne.write or screenTwo.write, etc.
    See the library here: https://github.com/energia/Energia/blob/master/examples/7.Display/LCD_5110/LCD_5110.cpp or https://github.com/energia/Energia/blob/master/examples/7.Display/LCD_5110_SPI/LCD_5110_SPI.cpp for the hardware SPI version.
  11. Like
    russcky reacted to rockskull in Real-Time Clock (RTC) Library for the MSP430/LaunchPad   
    I gotta try this one.. 
  12. Like
    russcky reacted to rockets4kids in Syncing a servo to audio   
    The MSP430 isn't capable of PWMing much more than 8-bit audio, and you aren't going to hear the difference in a small speaker anyways.  Although you could filter the audio on the MCU, it would be much easier to pre-process all your audio on the host and store it on the SD card along with your audio.  The SOX audio library will be your friend here.
  13. Like
    russcky reacted to spirilis in Music or Speech using MSP430G2553 and Energia   
    Also the 'sox' CLI program in Linux offers simple wav conversion stuff.
    Sent from my Galaxy Note II with Tapatalk 4
  14. Like
    russcky reacted to Rickta59 in Music or Speech using MSP430G2553 and Energia   
    The program Audacity provides many ways to resample and convert from compressed audio formats to raw PCM data.
  15. Like
    russcky reacted to piglet in My first ever electronics or micrcontroller project: Radio Word clock   
    I'm mostly a lurker on this forum, and watch in somewhat bemused awe at the things you folks manage to create. I'm right at the bottom of a massive learning curve with very little time to climb up it.
    Still, I'm very happy with my first ever electronics or microcontroller project. 
    It's a word clock inspired by an image of a commercial product I bumped into on the internet.
    Parts list:
    1) A cheap frame from our local hobby shop
    2) An http://www.pvelectronics.co.uk/index.php?main_page=product_info&products_id=2'>

  16. Like
    russcky got a reaction from JWoodrell in Music or Speech using MSP430G2553 and Energia   
    I found exactly what I was looking for here:  
    This is working great!
  17. Like
    russcky reacted to spirilis in Music or Speech using MSP430G2553 and Energia   
    Actually I should step up the pace on that project, because Halloween will be here before ya know it and I want to scare the bejesus out of the kids in my neighborhood  :grin:
    I have a PIR motion detector for this project too...
  18. Like
    russcky reacted to spirilis in Music or Speech using MSP430G2553 and Energia   
    That's pretty cool.  An "eventual" goal of mine is to store a couple minutes of PCM audio on a serial flash chip or something and stream it out using an MSP430F5172 with its Timer_D used for higher-resolution (e.g. hopefully 10 or 11 bit) output.
    I have the serial flash chip soldered to an SMD protoboard, just haven't got around to playing.
  19. Like
    russcky reacted to energia in Music or Speech using MSP430G2553 and Energia   
    That's pretty awesome! Great find!
  20. Like
    russcky got a reaction from spirilis in Music or Speech using MSP430G2553 and Energia   
    I found exactly what I was looking for here:  
    This is working great!
  21. Like
    russcky got a reaction from energia in Music or Speech using MSP430G2553 and Energia   
    I found exactly what I was looking for here:  
    This is working great!
  22. Like
    russcky reacted to mbeals in Syncing a servo to audio   
    I actually didn't get all that far with the audio.  The memory on the g2553 just wasn't large enough to do what I wanted it to do, and I had to switch focus to other projects before I came up with a solution.  I do plan on coming back to this project, but I will be using an ARM over the MSP.
  23. Like
    russcky got a reaction from cde in [Energia Library] Nokia 5110 LCD BoosterPack/Breakout PCB   
    @@cde thanx for the help!
    I spent a little time and got it working with a quick hex2int function that I then converted back to the resulting character and could send it back to the write function:
    // grab 2 hex chars from file stream code[0]=buffer[i]; code[1]=buffer[i+1]; //convert 2 hex chars to single int value between 0-255 and then to single char before sending to LCD myScreen.write(0x0c, char(hex2int(code,2)));  Thanx again!
  24. Like
    russcky reacted to cde in [Energia Library] Nokia 5110 LCD BoosterPack/Breakout PCB   
    ASCII 0 is Hex 0x30, ASCII F is 0x46. Without seeing the code you are using, I expect that's might be the issue. If you are not converting the ascii character to the proper value (subtract 0x30 for 0-9, subtract 0x31 for A-F [cap sensitive]) and anding them properly before sending them (you could be adding them backwards, i.e. you expect 0x01 but you are sending 0x10).
  25. Like
    russcky reacted to sirri in [Energia Library] Petit FatFS SD Card Library   
    hi.. just saw your posts..i was away for a while,.i will try this on monday nite
  • Create New...