• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » MSP430™ Microcontrollers » MSP430 Ultra-Low Power 16-bit Microcontroller Forum » write audio data in flash
Share
MSP430™ Microcontrollers
  • Forum
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
MSP430 Resources
  • MSP430 Product Folder
  • MSP-EXP430G2 - MSP430 LaunchPad Value Line Development kit
  • MSP430 Getting Started Guide
  • MSP430 Microcontroller Projects
  • More Resources >
  • write audio data in flash

    write audio data in flash

    This question is not answered
    Priyanka Dhomne
    Posted by Priyanka Dhomne
    on Aug 06 2012 08:17 AM
    Intellectual365 points

     hi  i am  working on MSP430F5438 
    if (bufferSize > 0)
    {
    //halLcdPrint(halUsbReceiveBuffer,OVERWRITE_TEXT);

    halLcdCursor();

    for(j=0;j < bufferSize;j++)
    {
    audioReceiveBuffer[j] = halUsbReceiveBuffer[j];
    //i++;
    }

    -------------------------------------------------------------------------------------------------------------------------------------------------

    void flash_audio_record()
    {
    int k = 0;
    int count = 4;
    unsigned char temp[4];
    unsigned long int data_32;

    memstart = 0X30000;
    memend = 0X31000;

    //flashEraseBank(MEM_START[0]);
    // flashEraseBank(MEM_START[1]);

    FCTL3 = FWKEY;
    FCTL1 = FWKEY + BLKWRT; // Flash UNLOCK
    halLcdPrintLine("Recording..", 6, INVERT_TEXT | OVERWRITE_TEXT);
    //halLcdClearScreen();
    //while(audioReceiveBuffer[j]!= '\0')

    while(memstart != 0x30999)
    {
    temp[k] = audioReceiveBuffer[j];

    //memstart = audioReceiveBuffer[j];
    k++;
    j++;
    if( j == count )
    {
    halLcdPrintLineCol((char*)temp,2,1,OVERWRITE_TEXT);
    LED_PORT_OUT |= LED_1;
    data_32 = temp[3];
    data_32 = data_32 >> 8;
    data_32 |= temp[2];
    data_32 = data_32 >> 8;
    data_32 |= temp[1];
    data_32 = data_32 >> 8;
    data_32 = temp[0];

    memstart = data_32; //4 bytes are loaded over flash memory location
    memstart++;
    count = count + 4;
    LED_PORT_OUT &= ~LED_1;
    }
    }
    lastaudiobyte = memstart;


    FCTL3 = FWKEY + LOCK; //Flash LOCK
    halLcdPrintLineCol("DONE", 6, 1, OVERWRITE_TEXT);
    halLcdPrintLineCol(" Stop ", 8, 1, OVERWRITE_TEXT);
    }

    why it is reseting the msp board m not getting problem pls help me out 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Aug 06 2012 10:54 AM
      Guru140650 points

      Where's you rmain code? Do you disable the watchdog timer? It will reset the MSP after 32ms otherwise (e.g. during the erase operation).
      Did you disable interrupts? Durign a flash write operation, interrupts msu tbe disabled or else the MSP will fetch teh 'busy' return value as interrupt vector address from the busy flash controller and then jump into the void.

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Priyanka Dhomne
      Posted by Priyanka Dhomne
      on Aug 06 2012 23:52 PM
      Intellectual365 points

      /*******************************************************************************
      Filename: usbTest.c

      Copyright 2008 Texas Instruments, Inc.
      *******************************************************************************/

      extern char halUsbReceiveBuffer[];
      extern unsigned char bufferSize;
      extern unsigned char audioReceiveBuffer[255];
      extern void flash_audio_record();
      extern void flash_audio_playback();

      extern void playback();

      void usbTest()
      {
      unsigned char quit=0,i=0 ,j=0;

      halButtonsInterruptEnable( BUTTON_ALL );
      halUsbInit();
      halLcdClearScreen();
      halLcdPrintLine("baudrate = 57600", 0, 0);
      halLcdPrintLine("Press R Buttons", 1, 0);


      while (quit == 0)
      {
      buttonsPressed = 0;

      __bis_SR_register(LPM3_bits + GIE);

      if (buttonsPressed & BUTTON_UP)
      halUsbSendChar('U');


      if (buttonsPressed & BUTTON_DOWN)
      halUsbSendChar('D');


      if (buttonsPressed & BUTTON_LEFT){
      halLcdPrintLine("playback", 2, 0);
      flash_audio_playback();}


      if (buttonsPressed & BUTTON_RIGHT)
      {
      halLcdPrintLine("record", 2, 0);
      flash_audio_record();
      }

      if (buttonsPressed & BUTTON_SELECT)
      {
      halUsbSendChar('Q');
      halLcdClearScreen();
      quit =1 ;
      }

      if (bufferSize > 0)
      {
      //halLcdPrint(halUsbReceiveBuffer,OVERWRITE_TEXT);

      halLcdCursor();

      for(j=0;j < bufferSize;j++)
      {
      audioReceiveBuffer[j] = halUsbReceiveBuffer[j];
      //i++;
      }
      // audioReceiveBuffer[bufferSize] = '\0';


      //halLcdPrint((char*)audioReceiveBuffer,OVERWRITE_TEXT);

      for (i = 0; i < bufferSize; i++)
      halUsbReceiveBuffer[i] = '\0';
      bufferSize = 0;
      }
      }

      halUsbShutDown();
      halLcdCursorOff();
      }

      /*******************************************************************************
      Filename: audio_playback.c

      *******************************************************************************/


      static unsigned long MEM_START[] = {0x30000, 0x40000};
      unsigned long memstart;
      unsigned long memend;
      unsigned long lastaudiobyte;
      unsigned char audioReceiveBuffer[255];

      unsigned char data;
      unsigned long PlaybackPtr;
      static int j = 0;

      void flash_audio_record();
      void flash_audio_playback();

      void flash_audio_record()
      {
      int k = 0;
      int count = 4;
      unsigned char temp[4];
      unsigned long int data_32;

      memstart = 0X30000;
      memend = 0X31000;

      //flashEraseBank(MEM_START[0]);
      // flashEraseBank(MEM_START[1]);

      FCTL3 = FWKEY;
      FCTL1 = FWKEY + BLKWRT; // Flash UNLOCK
      halLcdPrintLine("Recording..", 6, INVERT_TEXT | OVERWRITE_TEXT);
      //halLcdClearScreen();
      //while(audioReceiveBuffer[j]!= '\0')

      while(memstart != 0x30999)
      {
      temp[k] = audioReceiveBuffer[j];

      //memstart = audioReceiveBuffer[j];
      k++;
      j++;
      if( j == count )
      {
      halLcdPrintLineCol((char*)temp,2,1,OVERWRITE_TEXT);
      LED_PORT_OUT |= LED_1;
      data_32 = temp[3];
      data_32 = data_32 >> 8;
      data_32 |= temp[2];
      data_32 = data_32 >> 8;
      data_32 |= temp[1];
      data_32 = data_32 >> 8;
      data_32 = temp[0];

      memstart = data_32; //4 bytes are loaded over flash memory location
      memstart++;
      count = count + 4;
      LED_PORT_OUT &= ~LED_1;
      }
      }
      lastaudiobyte = memstart;


      FCTL3 = FWKEY + LOCK; //Flash LOCK
      halLcdPrintLineCol("DONE", 6, 1, OVERWRITE_TEXT);
      halLcdPrintLineCol(" Stop ", 8, 1, OVERWRITE_TEXT);
      }

      void flash_audio_playback()
      {
      // Power-up external hardware
      AUDIO_PORT_DIR |= AUDIO_OUT_PWR_PIN;
      AUDIO_PORT_OUT &= ~AUDIO_OUT_PWR_PIN;
      AUDIO_OUT_SEL |= AUDIO_OUT_PIN; // P4.4 = TB4
      LED_PORT_OUT |= LED_2;
      halLcdPrintLine(" playing ", 6, INVERT_TEXT | OVERWRITE_TEXT);
      PlaybackPtr = (unsigned long)(memstart);

      PlaybackPtr ++;
      // Setup Timer0_A for playback
      TBCTL = TBSSEL_2 + TBIE; // Use SMCLK as Timer0_A source,
      // Enable overflow interrupt
      TBCCR0 = 255; // Set output resolution (8 bit)
      //output time : 15.9 microsecond (255*62.5 nanosecond)(15.9*8 = 127 microsecond)
      // Add 10 counts of headroom for
      // loading TBCCR1
      TBCCR4 = 255 >> 1; // Default output ~Vcc/2

      TBCCTL4 = OUTMOD_7 + CLLD_1; // Reset OUT1 on EQU1, set on EQU0
      // Load TBCCR1 when TBR counts to 0
      TBCTL |= MC0; // Start Timer_B in UP mode
      // (counts up to TBCCR0)
      LED_PORT_OUT &= ~LED_2;

      halLcdPrintLineCol(" Stop ", 8, 1, OVERWRITE_TEXT);
      halButtonsInterruptDisable( BUTTON_S2 );
      // Activate LPM during DMA playback, wake-up when finished
      __bis_SR_register(LPM0_bits + GIE); // Enable interrupts, enter LPM0
      halLcdPrintLine(" DONE ", 6, INVERT_TEXT | OVERWRITE_TEXT);
      halButtonsInterruptEnable( BUTTON_S2 );
      halLcdPrintLineCol("Record", 8, 1, OVERWRITE_TEXT);
      halLcdPrintLineCol("Play", 8, 12, OVERWRITE_TEXT);
      // Power-down MSP430 modules
      TBCTL = 0; // Disable Timer_B PWM generation
      AUDIO_OUT_SEL &= ~AUDIO_OUT_PIN; // P4.4 = TB4

      buttonsPressed = 0;
      }

      #pragma vector=TIMERB1_VECTOR
      __interrupt void TIMERB1_ISR(void)
      {

      //static int counter = 0;
      switch (TBIV)
      {
      case 14 :
      // if (++counter == 8)
      //{
      // counter = 0;
      TBCCR4 = (*( (unsigned char*)PlaybackPtr) );//data lost 32bit-8bit = 24bits(3 Byte)(only last 8 bit data are transferred on output pin for playback)
      PlaybackPtr++;

      if ((unsigned long) PlaybackPtr >= (lastAudioByte))
      {
      TBCTL = 0;
      __bic_SR_register_on_exit(LPM0_bits);

      }
      //}
      }
      }

      yes watchdog timer Disabled in main and no interrupts are used except button interrupts in code I am trying to write audio data into flash which is coming from UART ,

      whether uart receive buffer size is 255 .and data coming is too large it is updating the usb buffer every time because of that data is not properly store at memstart......is this reason for reseting..........when it put loop like this it go into loop only once 

      while checking i print value of temp on LCD ,it must print updated value every time but it will not and when byte transferred from uart is exceeded 1245 it will reset the board

      while(audioReceiveBuffer[j]!= '\0')

      {

      halLcdPrintLineCol((char*)temp,2,1,OVERWRITE_TEXT);
      LED_PORT_OUT |= LED_1;
      data_32 = temp[3];
      data_32 = data_32 >> 8;
      data_32 |= temp[2];
      data_32 = data_32 >> 8;
      data_32 |= temp[1];
      data_32 = data_32 >> 8;
      data_32 = temp[0];

      memstart = data_32; //4 bytes are loaded over flash memory location
      memstart++;
      count = count + 4;
      LED_PORT_OUT &= ~LED_1;

      }

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use