• 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 » IAR Workbench (IAR Assembler)- MSP430
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 >
  • Forums

    IAR Workbench (IAR Assembler)- MSP430

    This question is answered
    sunil sharma
    Posted by sunil sharma
    on Aug 29 2011 05:48 AM
    Intellectual495 points

    Hi all,

    I am facing a small problem that whenever I debug my program, the Program Counter goes to 0xFFFE.

    Maybe it is due to some incorrect selection of option.

    I then take the PC to 0x2100 manually for stepwise execution.

    Thanks

    MSP430FG4618 IAR Embedded Workbench msp 430
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • sunil sharma
      Posted by sunil sharma
      on Sep 06 2011 04:55 AM
      Intellectual495 points

       Hi Michael,

      Created a new workspace and a new assembler only project with default settings. Then on debugging the PC went correctly to RESET (2100).
      Checked the INTVEC segment. It was at the right place.  -Z(CODE)INTVEC=FFC0-FFFF .

      Now I am trying to get the SPI going without any interrupt. When I run the code (GO) I get the error illegal opcode at 0x00. On single stepping the after reaching RETI this error is generated. 
      I also wanted to ask how to use interrupt for transmission . I tried a bit but could not succeed. Have removed that part from the code.

      Also, now I can't see the clock on  P7.3 or P1.4 on pressing GO...maybe because of this error

      The code is here

      #include  <msp430xG46x.h>       

                  RSEG    CSTACK                  ; Define stack segment
                  RSEG    CODE                    ; Assemble to Flash memory
      ;-----------------------------------------------------------------------------
      RESET       mov.w    #SFE(CSTACK),SP    ; Initialize stackpointer
      main           nop
      StopWDT     mov.w   #WDTPW+WDTHOLD+WDTNMI+WDTTMSEL+WDTSSEL,&WDTCTL  ; Stop WDT
      setupSVS    mov.b   #018h,&SVSCTL            ;Vth = 1.9V
      setupRTC    mov.b   #30h,&RTCCTL
      bis.b   #RTCBCD,&RTCCTL
      ;...............................................................................
                  mov.w   #TX_DATA,R15          ;ADDRESS OF TX_DATA IN R15
                  mov.w   #08,R10 

      TX_DATA     DB 01H
                        DB 02H
                  DB 03H
                  DB 04H
          DB 05H
                  DB 06H
                  DB 07H
                  DB 08H
      ;----------------------------------------------------------------
      ;CONFIGURE PORT8 FOR SELECTING THE SLAVE VIA 1:8 MUX-DEMUX
      ;----------------------------------------------------------------
      SetupP8     mov.b   #070h,&P8DIR            ;CONFIGURE THE PORT FOR S0,S1,S2
                  mov.b   #00h,&P8SEL  
                  mov.b   #000h,&P8OUT            ; SELECT DSP1 of 4 DSPs  
                 bic.b   #BIT0,&P7OUT;   MAKE SS LOW BY SETTING P7.0 LOW
      ;----------------------------------------------------------------;
      SETUP MSP430 FOR SPI-McBSP INTERFACE;
      -----------------------------------------------------------------    
      SetupSPI    ;bis.b   #UCSWRST,&UCA0CTL1 
                 bis.b   #UCMST+UCSYNC+UCCKPL+UCMSB,&UCA0CTL0;3-pin, 8-bit SPI master
                  bis.b   #UCSSEL_2,&UCA0CTL1     ; SMCLK
                  mov.b   #64h,&UCA0BR0           ; /2
                  clr.b   &UCA0BR1              ;
                 clr.b   &UCA0MCTL               ; No modulation

      ;Configure ports

      SetupP7    bis.b   #0Eh,&P7SEL             ; P7.3,2,1 option select as USCI_A0
                          bis.b   #01h,&P7DIR             ;Dirxn of STE as output as IO P7.0

                    bic.b   #UCSWRST,&UCA0CTL1      ; **Initialize USCI state machine**  ;...............................................................................

                  bic.b   #BIT0,&P7OUT             ; Now with SPI signals initialized,
                  bis.b   #BIT0,&P7OUT             ; reset slave; MAKE SS LOW BY SETTING P7.0 LOW - 

      ;Observe SMCLK on P1.4
                  BIS.B   #BIT4,&P1SEL ; Select SMCLK/n signal as output for port P1.4
                  BIS.B   #BIT4,&P1DIR ; Select port P1.4 to ACLK/n

                  mov.w   #50,R14                 ; Wait for slave to initialize
      waitForSlv     dec.w   R14                     ;
                  jnz     waitForSlv                     

      Mainloop   mov.b @R15+,&UCA0TXBUF
                 mov.w   #2,R11                  ; Add time between transmissions to
      cycleDelay dec.w   R11                     ; make sure slave can keep up
                 jnz     cycleDelay      

                 dec R10                         ;Tx 8 characters
               jnz Mainloop 
               reti         
      ;------------------------------------------------------------------------------
                  COMMON  INTVEC                  ; Interrupt Vectors
      ;------------------------------------------------------------------------------
                  ORG     RESET_VECTOR            ; MSP430 RESET Vector
                  DW      RESET                   ;
                  END

      And about starting another thread... you were right ..I shouldn't have because of the references....But I thought that the initial error was over and this was some other issue...

      IAR Embedded Workbench msp 430
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • sunil sharma
      Posted by sunil sharma
      on Sep 06 2011 05:07 AM
      Intellectual495 points

      the error for opcode was because I had default settings of debugger as simulator in the newly created project...

      saw a similar thread....

      can see the clock now...(SMCLK 297 KHz)

      Now I am trying to get the SPI going without any interrupt.  

      I also wanted to ask how to use interrupt for transmission/reception .

      I tried a bit but could not get it right.  Have removed that part from the code.

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Sep 06 2011 07:21 AM
      Verified Answer
      Verified by sunil sharma
      Guru140135 points

      sunil sharma
                  mov.w   #TX_DATA,R15          ;ADDRESS OF TX_DATA IN R15
                  mov.w   #08,R10 

      TX_DATA     DB 01H
                        DB 02H
                  DB 03H

      What are you doing here? After the mov.w instruction you have data. What is the processor supposed to do when it has executed mov.w? It will fetch the data as instructions and tries to execute them, resulting in whatever. If you're lucky, it will pass this part without doing any real harm, but it could do anything, depending on what this data means if takes as instruction.

      sunil sharma
               reti         ;

      Where do you return to? You never called this code as a function so there is nobody you could return to.
      Also, RETI means 'return from interrupt' (hence the 'i'). It means that the (by the interrupt logic) saved status register is fetched from stack, then the return address. But you are not in an interrupt, so the status register will be filled with the return address (maybe causing an LPM entry or whatever) and the last word on stack is taken as return address (jumping to whatever).
      But since you didn't call this function, there is no return address on stack too, so 'something' is fetched from stack as status register and return address. Since you never put something on stack at all, it is likely the first two words above the stack pointer: the first two words of your program.

      The proper exit of a function that has been called with the CALL instruction is RET.

      _____________________________________
      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.
    • sunil sharma
      Posted by sunil sharma
      on Sep 08 2011 14:05 PM
      Intellectual495 points

      Hi Michael


      1) I have removed the TX_DATA and RETI as you suggested 

      2) I am able to receive data on the DSP via SPI-McBSP. Howevr, when Iam transmitting from DSP to MSP -
      On transmitting 0/1h I am receiving 0 on MSP.
      On transmitting 2/3h I am receiving 1 
      On transmitting 4/5h I am receiving 2 

      Any idea why this is happening. On seeing the MISO line on scope , the graph for a 2/3h transmission from DSP look similar.
      Will post the graphs soon. But any idea what I should look for.

      3) On the IAR - When I press Go and run the code the transmission begins but on breaking the Pgm Counter reaches some place outside the code and does not return to RESET. However on running again it resumes normally. Is this alright.

      And thanks a ton for your constant guidance.
      You have been a real help..... 

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Sep 09 2011 10:39 AM
      Verified Answer
      Verified by sunil sharma
      Guru140135 points

      sunil sharma
      On transmitting 0/1h I am receiving 0 on MSP.
      On transmitting 2/3h I am receiving 1 
      On transmitting 4/5h I am receiving 2 

      THis look slike MSP and DSP are using a different clock phase or polarity. So you're one bit off. (5>>1 = 2, 4>>1 = 2, 3>>1=1 etc.)

      The USCI has settings for phase and polarity, you can play with them and see whether it solves the problem.

      _____________________________________
      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.
    • sunil sharma
      Posted by sunil sharma
      on Sep 09 2011 11:54 AM
      Intellectual495 points

      Will check the CLK phase and polarity.

      Presently the code is set to work without the Tx/Rx interrupt. I want to make it interrupt driven.

      I think that as the transmission from the MSP 430 may be without interrupt, but it is better to have an ISR for reception. The procedure for reception will start with the DSP generating an interrupt and then the MSP will have to initiate the RX_ ISR for reception.

      I also I wanted to know that -  When I press Go and run the code on MSP 430 the transmission begins but on breaking the Pgm Counter reaches some place outside the code and does not return to RESET. However on running again it resumes normally. Is this alright.

      And even on stopping by breaking the execution of the code, the MSP transmission the DSP continues to receive data. Is this because the SS sgl might be active for the slave.
      But there is no txn from the MSP 430. Even if something is there in the TXBUF the same value should be Txd over MOSI. Instead I continue to receive whatever I was Txg earlier that is 00h to 64h.

      Have placed the code as an attachment

      I may be asking all the questions for my convenience but I am working towards the same......

      Regards

      Sunil 

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • sunil sharma
      Posted by sunil sharma
      on Sep 09 2011 11:58 AM
      Intellectual495 points

      Forgot to attach the code

      1731.msp430.txt

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • sunil sharma
      Posted by sunil sharma
      on Sep 12 2011 07:24 AM
      Intellectual495 points

      Hi Michael
      Changed the polarity of the clk and getting the data correctly on both sides.

      Can you plz tell about some of my aueries in the previous post 

      Thanks

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Sep 14 2011 12:59 PM
      Verified Answer
      Verified by sunil sharma
      Guru140135 points

      sunil sharma
      Changed the polarity of the clk and getting the data correctly on both sides.

      Great.

      sunil sharma
      I think that as the transmission from the MSP 430 may be without interrupt, but it is better to have an ISR for reception. The procedure for reception will start with the DSP generating an interrupt

      Reception in the background is a good thing. However, if you want high speed transfers, a busy-waiting transfer is fastest. On the 5438, I do SPI transfers to/from SD card with full 16MHz SPi clock (2MB/s peak transfer rate). Well, the wait times for fetching a block or writing it drop the overall performance, but with interrupts, I wouldn't come near this speed.
      For the (slower) UARTs, I use ISR s with a ring buffer for sending and receiving. When I have to send something, i can fire&forget, and I can check whether something was received when my code wants to (either getting something from the buffor or gettign a timeout). That's really convenient.

      For I2C, I too prefer busy-waiting but this depends on the type of information you want to transfer. (on short transfers, the setup overhead is much larger than what you gain for a background handling)

      sunil sharma
      and then the MSP will have to initiate the RX_ ISR for reception.

      You cannot call an ISR from main directly. This will crash the system. An ISR expects the status register on the stack after the return address (which you cannot simulate easily in software).

      sunil sharma
      On the IAR - When I press Go and run the code the transmission begins but on breaking the Pgm Counter reaches some place outside the code and does not return to RESET. However on running again it resumes normally. Is this alright.

      Hmm, strange. Normally, it should break where you currently are and not in the void.
      Why should it return to RESET? When you break the execution, you should stop somewhere in the main loop.

      sunil sharma
      And even on stopping by breaking the execution of the code, the MSP transmission the DSP continues to receive data. Is this because the SS sgl might be active for the slave.


      Strange again. When the MSP is slave, then stopping the CPU does nto stop the USCI. The clock is provided externally, so teh external master continues to clock the bus and sends data, and when the USCIs TX buffer is empty, it will continue sending, well, I don't know what i sends then.

      If the MSP is master, then ther eare two possibilities: eithe rthe clock that drives the USCI is stopped by the debugger too, then the SPI immediately stops sending. On some slaves, the transfer can be continued after any delay, on some there will be a timeout.

      If the clock is not stopped by the debugger (not possible on some devices, or not selected in the config), then the SPI sends until TXBUF is empty and then stops, since the CPU is not stuffing more into TXBUF.

      When you see it continuing, it looks like there is a problem with the debug interface (and the wrong display of teh code address fits to this assumption). If so, I cannot help you there. I don't use IAR or CCS. I don't even use a debugger at all for my MSP projects.

      _____________________________________
      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.
    • sunil sharma
      Posted by sunil sharma
      on Sep 14 2011 14:43 PM
      Intellectual495 points

      Jens-Michael Gross

      Reception in the background is a good thing.
      My aim is to interface the master with 4 DSP slaves. The connection is as shown

      Now I have been able to undertake simple SPI communication between MSP430 and DSp1.

      However, it is actually supposed to work like this

      a) DSP1/2/3/4 interrupts MSP430 using HINTDSP via a priority encoder.      The priority encoder output (HINT1,2,3) is connected with pins P1.2/4/6.

      b) The MSP430 decodes/finds which DSP has generated interrupt and then initiates communication with that DSP.

      c) This is why I was thinking of using interrupts and ISRs to select the appropriate DSP for communication.

      d) There is another signal from the encoder to the DSP HINT# connected at P2.6, which changes state on any DSP sending a request for communication.

      I am planning to use this P2.6 as an interrupt pin and thereafter having an ISr to check the P1IN register for the highest priority DSP which has generated the request.

      Is this okay to go ahead with, or shall I do it differently.

      sunil sharma
      and then the MSP will have to initiate the RX_ ISR for reception.

      You cannot call an ISR from main directly. This will crash the system. An ISR expects the status register on the stack after the return address (which you cannot simulate easily in software).

      If I cannot use an ISR, then what is the way out???

      I dont require high speed data transfers. The DSPs will mostly be sending health data or some processed data or results.
      Will it be alright to establish communication with each DSP in a sequential manner and receive any data if it is there. However, i feel this will lead to keeping MSP and DSP unnnecessarily busy if the DSPs are in sleep mode and dont have anything to transmit. Hence not an ideal solution.

      Thanks

       

       

      msp 430 c5510
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • sunil sharma
      Posted by sunil sharma
      on Oct 03 2011 04:10 AM
      Intellectual495 points

      Hi Michael,

      I am trying to interface a FLASH to MSP430 using SPI. Can you help me with it. Here is the link for the thread

      http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/p/137111/496266.aspx#496266

      Regards..

      Sunil

      SPI Flash msp 430
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    12
    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