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.
The Rev C chip SVSH reset saves 0x0002 3021 instead of the actual count while active mode power-down with Launchpad supercap.
Here is the commented Mecrisp Forth code base:
\ svsh1.fs \ \ Steps to implement: \ \ 1 flash launchpad with msp430fr5994.hex \ 2 download and run folie from github.com/.../releases \ 3 select correct serial port in folie ( raw mode and 115 kbaud might be needed ) \ 4 reset or enter for welcome message \ 5 1 1 + gives 2 ok \ !send svsh1.fs \ reset to wake up led - enter to toggle led2 \ unplug board and wait for complete power down \ type show for diagnostics \ \ svsh test 1 for msp430fr5994 \ ============================ \ Only state 1-3 is implemented: \ \ 1. normal running on power state with led1 and led2 on. ( led2 is toggled under rx ) \ 2. lpm3.5 state - only the 32-bit epoch counter is running and led1 is toggled. \ 3. no-power state \ \ The following transitions are defined: \ \ 1-2: triggered by s1 \ 2-3: interrupt triggered by SVSH is used to save counter to fram \ 3-1: repowering the device and normal startup and counter re-load \ 1-3: triggered by no-power shutdown, also under SVSH interrupt \ 2-1-2: wake up interrupt triggered by s2 \ \ Notes: \ \ - for testing led 1 is jumpered to j1.1 (3v3) to drain supecap. \ - the launchpad is unplugged to drain cap and cause 1-3 \ - SVSH interrupt will be followed by BOR. \ eraseflash compiletoflash \ define msp430fr5994 constants used $01 constant .0 $02 constant .1 $04 constant .2 $08 constant .3 $10 constant .4 $20 constant .5 $40 constant .6 $80 constant .7 $0100 constant .8 $0200 constant .9 $0400 constant .10 $0800 constant .11 $1000 constant .12 $2000 constant .13 $4000 constant .14 $8000 constant .15 $0200 constant P1Base \ P1, P2 Registers (Base Address: 0200h) $0320 constant PJBase \ PJ Registers (Base Address: 0320h) $02 constant PxOUT \ Port Px output P1OUT 02h $04 constant PxDIR \ Port Px direction P1DIR 04h $0A constant PxSEL0 \ Port Px selection 0 P1SEL0 0Ah $0120 constant PMMBase $A5 constant PWD_PMM .2 constant PMMSWBOR $00 constant PMMCTL0 $01 constant PMMPW $0A constant PMMIFG $10 constant PM5CTL0 .0 constant LOCKLPM5 $019E constant SYSRSTIV $04A0 constant RTCBASE \ RTC_C Registers (Base Address: 04A0h) $A5 constant PWD_RTC $01 constant RTCPWD \ RTC password RTCPWD 01h $02 constant RTCCTL1 \ RTC control 1 RTCCTL1 02h .6 constant RTCHOLD \ 6 RTCHOLD RW 1 for hold .3 constant RTCSSEL \ 3-2 1x SSEL RT1PS $08 constant RTCPS0CTL \ RTC prescaler 0 control RTCPS0CTL 08h .13 .12 + .11 + constant RT0PSDIV \ 13-11 111 = Divide by 256 $0A constant RTCPS1CTL \ RTC prescaler 1 control RTCPS1CTL 0Ah .15 constant RT1SSEL \ 15-14 1x SSEL RT0PS .13 .12 + constant RT1PSDIV \ 13-11 110 = Divide by 128 .4 .3 + constant RT1IP \ 4-2 RT1IPx RW 0h 110b = Divide by 128 for 1 Hz $10 constant RTCCNT12 \ RTC seconds/counter 12 RTCSEC/RTCNT1 10h $10 constant RTCCNT1 \ RTC seconds/counter 1 RTCSEC/RTCNT1 10h $11 constant RTCCNT2 \ RTC minutes/counter 2 RTCMIN/RTCNT2 11h $12 constant RTCCNT34 \ RTC hours/counter 34 RTCHOUR/RTCNT3 12h $12 constant RTCCNT3 \ RTC hours/counter 3 RTCHOUR/RTCNT3 12h $13 constant RTCCNT4 \ RTC day of w/counter 4 RTCDOW/RTCNT4 13h \ : toggle1 ( -- ) \ Toggles P1.0 .0 PxOUT P1Base + cxor! ; : toggle2 ( -- ) \ Toggles P1.1 .1 PxOUT P1Base + cxor! ; : on1 ( -- ) .0 PxOUT P1Base + cbis! ; \ read and print conters : 2sec. ( -- ud ) \ read 32-bit counter ( no hold checks ) RTCCNT1 RTCBASE + 2@ swap hex. hex. ; \ information memory as follows $1800 constant TRAPDOOR \ reset function pointer $1802 constant CNT1 $1803 constant CNT2 $1804 constant CNT3 $1805 constant CNT4 $1806 constant RSTP \ reset pointer : swbor ( -- na ) \ software defined BOR with trapdoor bypass true TRAPDOOR ! \ reset trapdoor first PWD_PMM PMMPW PMMBase + c! \ unlock PMM PMMSWBOR PMMCTL0 PMMBase + cbis! \ BOR 0 PMMPW PMMBase + c! \ lock PMM ; : svshreset ( -- ) LOCKLPM5 PM5CTL0 PMMBase + bic! \ clear LOCKLPM5 (nop) RTCCNT1 RTCBASE + c@ CNT1 c! \ RTCCNT2 RTCBASE + c@ CNT2 c! \ RTCCNT3 RTCBASE + c@ CNT3 c! \ RTCCNT4 RTCBASE + c@ CNT4 c! \ true TRAPDOOR ! \ clear trapdoor 2 RSTP +! \ inc rstp RTCCNT1 RTCBASE + c@ 10 + $FF and \ RTCCNT1 + 10 begin \ wait dup RTCCNT1 RTCBASE + c@ = until drop \ wait for bor swbor ( -- na ) \ terminate program flow ; : wake-up ( -- ) \ init placeholder for trapdoor startup configuration PMMIFG PMMBase + @ $1808 RSTP @ + ! \ log PMMIFG 2 RSTP +! SYSRSTIV @ dup RSTP @ $1808 + ! \ log SYSRSTIV case \ SYSRSTIV case $0E of \ SVSH = $0E svshreset endof endcase 2 RSTP +! true TRAPDOOR ! \ clear trapdoor swbor \ normal reset ; : eraseflash ( -- ) true TRAPDOOR ! \ cancel trapdoor eraseflash \ chain ; : zero ( -- ) cr ." Reading SYSRSTIV:" begin SYSRSTIV @ dup cr ." = " hex. 0= until cr 0 RSTP ! true CNT1 ! true CNT3 ! ; : show ( -- ) \ read log info from information memory cr cr ." 2sec. = " 2sec. cr ." 0x1800 = " TRAPDOOR @ hex. ." (TRAPDOOR)" cr ." 0x1802 = " CNT1 @ hex. ." (CNT12)" cr ." 0x1804 = " CNT3 @ hex. ." (CNT34)" cr cr ." 0x1806 = " RSTP @ hex. ." (RSTP)" RSTP @ 4 / 0 ?do cr ." 0x" $1808 i 4 * + dup hex. ." = " @ hex. ." (PMMIFG)" cr ." 0x" $180A i 4 * + dup hex. ." = " @ hex. ." (SYSRSTIV)" loop cr zero ; : serial-key toggle2 serial-key ; \ line rx will toggle led2 : init .0 .1 + PxDIR P1Base + c! \ P1, P2 clear P1.0 and P1.1 to LED output direction on1 \ led1 on \ rtc setup .4 PxSEL0 PJBase + c! \ PJ SEL0 lfxt PWD_RTC RTCBASE RTCPWD + c! \ unlock RTCSSEL RTCBASE RTCCTL1 + c! \ setup counter mode. RT0PSDIV RTCBASE RTCPS0CTL + ! RT1SSEL RT1PSDIV + RT1IP + RTCBASE RTCPS1CTL + ! RTCHOLD RTCBASE RTCCTL1 + cbic! \ clear the RTCHOLD and bit to start the counter. 0 RTCBASE RTCPWD + c! \ lock \ arm trapdoor ['] wake-up TRAPDOOR ! \ actvate reboot trapdoor ['] serial-key hook-key ! \ fuction pointer cr ." Type 'show' to typeand reset log:" cr ;
Here are the diagnostics:
\ download msp430fr5994.hex ok. Mecrisp 2.0.7 for MSP430FR5994 by Matthias Koch .1 \ send svsh.fs ok. !send svsh1.fs 1> svsh1.fs 37: Mecrisp 2.0.7 for MSP430FR5994 by Matthias Koch .1 1> svsh1.fs 148: Redefine eraseflash. ok. 1> svsh1.fs 179: Redefine serial-key. ok. \ press Launchpad reset ok. Mecrisp 2.0.7 for MSP430FR5994 by Matthias Koch .1 Type 'show' to type and reset log: \ type show ok. show 2sec. = 0010 34DE 0x1800 = 452E (TRAPDOOR) 0x1802 = FFFF (CNT12) 0x1804 = FFFF (CNT34) 0x1806 = 0000 (RSTP) Reading SYSRSTIV: = 0004 = 0000 ok. \ type show again ok. show 2sec. = 0010 34F3 0x1800 = 452E (TRAPDOOR) 0x1802 = FFFF (CNT12) 0x1804 = FFFF (CNT34) 0x1806 = 0000 (RSTP) Reading SYSRSTIV: = 0000 \ disconnect and wait for led1 to power down - svsh reset ok. . . . \ move cap link to "charge" and reconnect [WRITE ERROR! /dev/serial/by-path/pci-0000:00:14.0-usb-0:2:1.2] [disconnected] no such file or directory [connected to pci-0000:00:14.0-usb-0:2:1.2] ok. ok. ok. ok. \ type show to view diagnostics ok. show 2sec. = 0000 3038 0x1800 = 452E (TRAPDOOR) 0x1802 = 3021 (CNT12) 0x1804 = 0002 (CNT34) 0x1806 = 0004 (RSTP) 0x1808 = 2000 (PMMIFG) 0x180A = 000E (SYSRSTIV) Reading SYSRSTIV: = 0002 = 0000 ok.
Dear Wei,
Thanks for getting back to me!
Here is my response:
Did you check for the RTCCNT1, RTCCNT2, RTCCNT3 and RTCCNT4 value when the MCU is not powered down, i.e before SVSH reset?
- Yes, I did and it reads and saves correctly.
I can also confirm that CNT1, CNT2, CNT3 and CNT4 saves correctly to FRAM after SVSH reset.
The issue is that the RTCCNT1, RTCCNT2, RTCCNT3 and RTCCNT4 reads report the incorrect value.
May I suggest you try the following:
- set up the 32-bit one second counter
- wait for SVSH (with supercap discharging under led1)
- save RTCCNT1, RTCCNT2, RTCCNT3 and RTCCNT4 to FRAM
And report your finding to me please. I can read - but I do not like to code in assembler and C.
c-:
Here is my first draft. LED1 not working. Please assist.
I am using the CCS Linux version. I cannot get hold of the hex file to if the correct code is downloaded?
;------------------------------------------------------------------------------- ; MSP430 Assembler Code Template for use with TI Code Composer Studio ; ; ;------------------------------------------------------------------------------- .cdecls C,LIST,"msp430.h" ; Include device header file ;------------------------------------------------------------------------------- .def RESET ; Export program entry-point to ; make it known to linker. ;------------------------------------------------------------------------------- .text ; Assemble into program memory. .retain ; Override ELF conditional linking ; and retain current section. .retainrefs ; And retain any sections that have ; references to current section. ;------------------------------------------------------------------------------- RESET mov.w #__STACK_END,SP ; Initialize stackpointer StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer ;------------------------------------------------------------------------------- ; SVSH reset code here ;------------------------------------------------------------------------------- cmp.b #0x0E, &SYSRSTIV ; Check if reset is SVSH jne SKIPSVSH mov.b &RTCCNT1, &CNT1 mov.b &RTCCNT2, &CNT2 mov.b &RTCCNT3, &CNT3 mov.b &RTCCNT4, &CNT4 add.w #1, &RESETCNT SKIPSVSH: ;------------------------------------------------------------------------------- ; LED1 on code here ;------------------------------------------------------------------------------- bis.b #1, &P1DIR bis.b #1, &P1OUT ;------------------------------------------------------------------------------- ; Main loop here ;------------------------------------------------------------------------------- MainLoop: nop xor.b #1, &P1OUT jmp MainLoop nop ;------------------------------------------------------------------------------- ; Information memory definitions ;------------------------------------------------------------------------------- .data 0x1800 CNT1 .byte 0xFF CNT2 .byte 0xFF CNT3 .byte 0xFF CNT4 .byte 0xFF RESETCNT .word 0xFFFF ;------------------------------------------------------------------------------- ; Stack Pointer definition ;------------------------------------------------------------------------------- .global __STACK_END .sect .stack ;------------------------------------------------------------------------------- ; Interrupt Vectors ;------------------------------------------------------------------------------- .sect ".reset" ; MSP430 RESET Vector .short RESET
**Attention** This is a public forum