Hello Everyone,
i am currently trying to realize certain some small scale projects with the MSP430. My latest project consists of a gold-cap powered F2002 which is turning on a LED if a light sensor detects darkness. The 1 Farad gold-cap is charged by a solar cell. The hardware works fine. However, it seems as if the MSP is using too much power.
The 1 F capacitor will discharge from 3.6V to 1.8V within 1 hour (LED not working of course). i pulled the RST pin to Ground and the result was a much lower power consumption, so the problems clearly originates from the MSP430.
i attached my Assembler Code. Hope, anyone finds a mistake in it, so there is a way to improve this.
#include "msp430f2002.h"
;-------------------------------------------------------------------------------
main ORG 0FC00h ; Progam Start (1K Flash device)
;-------------------------------------------------------------------------------
RESET mov.w #0280h,SP ; Set stackpointer (128B RAM device)
SetupP1
mov.b #0FEh,&P1DIR ; Set P1.1 - P1.7 to output 11111110
mov.b #0C0h,&P2DIR ; Set P2.6 - P2.7 to output 11000000
mov.b #000h,&P1OUT ; All Outputs to 0
mov.b #001h,&P1SEL ; Set P1.0 to Fkt Mode
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer
BASIC_T
bic.b #XTS,&BCSCTL1 ;
bis.b #XT2OFF,&BCSCTL1
bis.b #SELM_3,&BCSCTL2
bis.b #LFXT1S_2,&BCSCTL3 ; Use VLO
TA_INIT
clr.w &TACTL
mov.w #CCIE,&TACCTL0
mov.w #01000h,&TACCR0
mov.w #TASSEL_1+ID_2,&TACTL
bis.w #MC_1,&TACTL
ADC_INIT
mov #SREF_1+ADC10SR+REFBURST+REFON+ADC10ON,&ADC10CTL0
bis.b #BIT0,&ADC10AE0
;--- Registerinit ---
REG_INIT clrc
mov #0000h,R5 ; R5 = Analog Value n
mov #0000h,R6 ; R6 = Analog Value n-1
mov #00C0h,R7 ; R7 = Value Darkness
mov #0000h,R8 ; R8 = Temp Result
mov #00A0h,R9 ; R9 = Value Change
;--- LPM CPU ---
eint
LPM nop
bis.w #CPUOFF+SCG1+SCG0+GIE,SR ; Enter LPM3
nop
jmp LPM
;--- Interrupt Service Routinen ---
;--- Isr TA0 ---
TA0_ISR
nop
dint
cont mov.w #01000h,&TACCR0
bic.b #BIT3,&P1OUT
bis #ENC+ADC10SC+ADC10ON,&ADC10CTL0
Wait bit #ADC10IFG,&ADC10CTL0
JZ Wait
mov.w R5,R6
mov.w &ADC10MEM,R5
bic #ENC+ADC10SC+ADC10ON,&ADC10CTL0
cmp.w R5,R7 ; R7 - R5
JLO Nacht ; R7 < R5
JMP End_Isr
Nacht mov.w R5,R8 ; copy n Value to R8
sub R6,R8 ; R8 - R6 -> R8, (Value n) - (Value n-1)
bit #BIT2,SR ; Result negative?
JNZ End_Isr ; if n < n-1
cmp.w R9,R8 ; R8 - R9
JLO End_Isr ; R8 < R9
bis.b #BIT3,&P1OUT
mov.w #0FFFFh,&TACCR0
End_Isr bic #TAIFG,&TACTL
bic #ADC10IFG,&ADC10CTL0
bic #CPUOFF+SCG1+SCG0,0(SP)
eint
reti
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
ORG 0FFFEh ; MSP430 RESET Vector
DW RESET
ORG 0FFF2h ; Timer_A0 Vector
DW TA0_ISR
END
Thanks a lot!
Andy