This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR2433: MSP430 Not working when on external power mode. Works fine when connected to PC

Part Number: MSP430FR2433
Other Parts Discussed in Thread: TLV700

So basically, I have two msp430fr2433 boards, both with HC05, set as master and slave. When connected to the PC and debugging. The slave msp430 gets the data and switches the relays fine. But when I put it on an external power supply, it won't do anything even though the HC05 are connected to each other.

CODE:

#include "msp430.h" ; #define controlled include file

NAME main ; module name

PUBLIC main ; make the main label vissible
; outside this module
ORG 0FFFEh
DC16 init ; set reset vector to 'init' label

RSEG CSTACK ; pre-declaration of segment
RSEG CODE ; place program in 'CODE' segment
RSEG DATA16_N
RXData DW 10h
PreData DW 10h
init: MOV #SFE(CSTACK), SP ; set up stack

main: NOP ; main program
MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer
bic.w #LOCKLPM5,PM5CTL0
;18:E4:35F093 <-- Bluetooth Address

;Ports
bis.b #BIT0, P1DIR
bic.b #BIT0, P1OUT
;Relay Ports Open
bis.b #BIT0, P2DIR
bis.b #BIT1, P2DIR
bis.b #BIT5, P2DIR
bis.b #BIT6, P2DIR
;Initalize Ports
bis.b #BIT0, P2OUT
bis.b #BIT1, P2OUT
bis.b #BIT5, P2OUT
bis.b #BIT6, P2OUT
;Testing Motors
;Forward
bic.b #BIT0, P2OUT
bis.b #BIT1, P2OUT
bic.b #BIT5, P2OUT
bis.b #BIT6, P2OUT
;Backward
bis.b #BIT0, P2OUT
bic.b #BIT1, P2OUT
bis.b #BIT5, P2OUT
bic.b #BIT6, P2OUT
;Test Output
;STOP
bis.b #BIT0, P2OUT
bis.b #BIT1, P2OUT
bis.b #BIT5, P2OUT
bis.b #BIT6, P2OUT


bis.w #SCG0, SR
bis.w #SELREF__REFOCLK, &CSCTL3 ;Creates reference for Clock Source = REFOCLK
mov.w #0, &CSCTL0
bic.w #DCORSEL_7, &CSCTL1 ; Clear data @ CSCTL1
bis.w #DCORSEL_3, &CSCTL1 ;Set DCO for 1 MHZ Operation
mov.w #FLLD_0+243, &CSCTL2 ;FLLD+30 = FLLD for 8mhz DCO
nop
nop
nop
bic.w #SCG0, SR

unlockFLL:
mov.w &CSCTL7, R13
and.w #FLLUNLOCK0|FLLUNLOCK1, R13
jnz unlockFLL

mov.w #SELMS__DCOCLKDIV+SELA__REFOCLK, &CSCTL4

bis.b #BIT4+BIT5, &P1SEL0
bis.w #UCSWRST, &UCA0CTLW0
bis.w #UCSSEL__SMCLK,&UCA0CTLW0

mov.b #65, &UCA0BR0
mov.b #3, &UCA0BR1
bis.w #UCBRS2, &UCA0MCTLW
bic.w #UCSWRST, &UCA0CTLW0
clr.w RXData

MainLoop:
bis.w #UCRXIE, &UCA0IE
cmp.w RXData, PreData
jeq Skip

cmp.w #0x02, RXData
jeq Forward
cmp.w #0x01, RXData
jeq Backward
cmp.w #0x00, RXData
jeq Stop

jmp Skip
Forward:
bic.b #BIT0, P2OUT
bis.b #BIT1, P2OUT
bic.b #BIT5, P2OUT
bis.b #BIT6, P2OUT
mov.w RXData, PreData
jmp MainLoop
Backward:
bis.b #BIT0, P2OUT
bic.b #BIT1, P2OUT
bis.b #BIT5, P2OUT
bic.b #BIT6, P2OUT
mov.w RXData, PreData
jmp MainLoop
Stop:
bic.b #BIT0, P2OUT
bic.b #BIT1, P2OUT
bic.b #BIT5, P2OUT
bic.b #BIT6, P2OUT
mov.w RXData, PreData
jmp MainLoop
Skip:
bis.w RXData, PreData
jmp MainLoop
USC_ISR:
mov.w &UCA0RXBUF, RXData
bic.w #UCRXIFG, &UCA0IFG
bic.w #UCRXIE, &UCA0IE
reti


COMMON INTVEC
org USCI_A0_VECTOR
dw USC_ISR
END

This is how the MSP430 receiver is setup. Works fine if it's connected to a computer, but stops completely when its on an external power supply. Any suggestions would be greatly appreciated!

  • 1) I don't see where you're enabling global interrupts (GIE). Is there some code missing?
    2) I suggest you make a "startup blinky" on one of the Launchpad LEDs (P1.0, e.g.), very early into startup, so you get a progress report.
    3) As near as I can tell, you're feeding 6V (4xAA cells) into the 5V pin. The TLV700 is only rated up to 5.5V in. More generally, I don't think J6 is intended for powering the Launchpad, so there may be some other impediment I don't see.
    4) When you're debugging, the HC05 is powered all the time. It may take some time for it to start after a power-up.
  • 1. Good eyes. I have no idea why I did that either. Will try in the morning
    2. Will try in the morning
    3. Seems to be working fine with no failure, so will test for a couple more days and get back with an answer
    4. HC05 turns on immediately.

    Thanks for the reply. I will test in the morning and let you know what happens.
  • Tested (2). Works fine
    Enabled GIE. Doesn't work.
  • How do you know the HC-05s are running? Is the transmitter transmitting anything? Is the receiver receiving anything?
  • Pretty sure now it's just something wrong with the programming. Because I have a Timer setup and it's blinking a light on the MSP430. Same circuit with relays on a different 5v source.

    BIS.W #SELMS__VLOCLK, &CSCTL4
    ;BIC.W #OFIFG, &SFRIFG1
    ;BIS.W #SCG0, SR
    ;BIS.W #SCG1, SR
    BIC.W #LOCKLPM5, &PM5CTL0 ;Unlock I/O Pins
    BIS.B #1h, &P1DIR

    BIS.W #CCIE, &TA0CCTL0 ;Timer 0 interrupt Enable
    MOV.W #32000, &TA0CCR0
    BIS.W #TASSEL_1|MC_1, &TA0CTL
    NOP
    BIS.W #LPM3 + GIE, SR
    ;BIS.W #CPUOFF + GIE, SR
    NOP

    JMP $ ; jump to current location '$'


    TIMER:
    XOR.B #1h, &P1OUT
    reti

    Here is the code for the setup i'm using.
    The HC-05 has a built in light and lets me know that they are connected.
  • So what is it that isn't working right?

    I'm still concerned that it "work[ed] fine" without the GIE. I see where you initialize RXData, but initialization of PreData is at best circuitous. When debugging, an uninitialized variable could retain its value over multiple sessions (e.g. set to 3 two hours ago), but after a power cycle it could be anything. I suggest you also initialize PreData, maybe to something preposterous like 0xFF.
  • Hi,

    the most critical item why it is not working  without debugger is that you have place your code in RAM and the is gone after a power cycle.

    The RSEG .... instruction tell the assembler where to place the following code or data.

    With

    RSEG CODE ; place program in 'CODE' segment

    RSEG DATA16_N

    RXData DW 10h

    PreData DW 10h

    init: MOV #SFE(CSTACK), SP ; set up stack

    you do place the code starting with init label into DATA16_N and this is RAM.

    So with that sequence

    RSEG CSTACK ; pre-declaration of segment

    RSEG DATA16_N

    RXData DW 10h

    PreData DW 10h

    RSEG CODE ; place program in 'CODE' segment

    init: MOV #SFE(CSTACK), SP ; set up stack

    main: NOP ; main program

    It will place the code in FLASH

    Regards,

    Stefan

  • Holy crap, you're a genius. Now I know a little more. Thank you!

**Attention** This is a public forum