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
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 stackpointermain nopStopWDT mov.w #WDTPW+WDTHOLD+WDTNMI+WDTTMSEL+WDTSSEL,&WDTCTL ; Stop WDTsetupSVS mov.b #018h,&SVSCTL ;Vth = 1.9VsetupRTC mov.b #30h,&RTCCTLbis.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 initializewaitForSlv dec.w R14 ; jnz waitForSlv
Mainloop mov.b @R15+,&UCA0TXBUF mov.w #2,R11 ; Add time between transmissions tocycleDelay 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...
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.
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
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.
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.....
sunil sharmaOn 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
The USCI has settings for phase and polarity, you can play with them and see whether it solves the problem.
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
Forgot to attach the code
1731.msp430.txt
Hi MichaelChanged 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
Hi MichaelChanged 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
sunil sharmaChanged the polarity of the clk and getting the data correctly on both sides.
sunil sharmaI 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.
sunil sharmaOn 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.
sunil sharmaAnd 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.
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.
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
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.
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.
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..