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.

CCS/MSP430FR5972: simple main.c - MPU problem...

Part Number: MSP430FR5972
Other Parts Discussed in Thread: MSP430WARE, MSP430FR6972, MSP-TS430PM64F, MSP-EXP430FR6989, MSP430FR5969

Tool/software: Code Composer Studio

Hi All!

1) Clear installation of CCS 8.1.0

2) create "simple main.c program:

#include <msp430.h> 


/**
 * main.c
 */
int main(void)
{
	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
	
	return 0;
}

2) compile this : -vmsp --code_model=small --data_model=small -O4 --opt_for_speed=5 --use_hw_mpy=32 --include_path="C:/ti/ccs8/ccsv8/ccs_base/msp430/include" --include_path="C:/alex/ti/workspace_v8/ZU_v7_FR5972" --include_path="C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --advice:power=all --advice:hw_config=all --define=__MSP430FR5972__ --define=_MPU_ENABLE --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40

linker flags: -vmsp --code_model=small --data_model=small -O4 --opt_for_speed=5 --use_hw_mpy=32 --advice:power=all --advice:hw_config=all --define=__MSP430FR5972__ --define=_MPU_ENABLE --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 -z -m"ZU_v7_FR5972.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccs8/ccsv8/ccs_base/msp430/include" -i"C:/ti/ccs8/ccsv8/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccs8/ccsv8/ccs_base/msp430/lib/FR59xx" -i"C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/lib" -i"C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --priority --reread_libs --define=_MPU_ENABLE --diag_wrap=off --display_error_number --warn_sections --xml_link_info="ZU_v7_FR5972_linkInfo.xml" --use_hw_mpy=F5 --rom_model

Result - 7 errors

**** Build of configuration Release for project ZU_v7_FR5972 ****

"C:\\ti\\ccs8\\ccsv8\\utils\\bin\\gmake" -k -j 8 all -O 
 
Building file: "../main.c"
Invoking: MSP430 Compiler
"C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmsp --code_model=small --data_model=small -O4 --opt_for_speed=5 --use_hw_mpy=32 --include_path="C:/ti/ccs8/ccsv8/ccs_base/msp430/include" --include_path="C:/alex/ti/workspace_v8/ZU_v7_FR5972" --include_path="C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --advice:power=all --advice:hw_config=all --define=__MSP430FR5972__ --define=_MPU_ENABLE --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --preproc_with_compile --preproc_dependency="main.d_raw"  "../main.c"
Finished building: "../main.c"
 
Building target: "ZU_v7_FR5972.out"
Invoking: MSP430 Linker
"C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmsp --code_model=small --data_model=small -O4 --opt_for_speed=5 --use_hw_mpy=32 --advice:power=all --advice:hw_config=all --define=__MSP430FR5972__ --define=_MPU_ENABLE --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 -z -m"ZU_v7_FR5972.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccs8/ccsv8/ccs_base/msp430/include" -i"C:/ti/ccs8/ccsv8/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccs8/ccsv8/ccs_base/msp430/lib/FR59xx" -i"C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/lib" -i"C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --priority --reread_libs --define=_MPU_ENABLE --diag_wrap=off --display_error_number --warn_sections --xml_link_info="ZU_v7_FR5972_linkInfo.xml" --use_hw_mpy=F5 --rom_model -o "ZU_v7_FR5972.out" "./main.obj" "../lnk_msp430fr5972.cmd"  -llibmpu_init.a -llibmath.a -llibc.a 
<Linking>
>> WARNING: --use_hw_mpy compiler setting (32) does not match linker setting (F5).  Both options will be set to compiler setting.
warning #10204-D: could not resolve index library "libmpu_init.a" to a compatible library
warning #10204-D: could not resolve index library "libmath.a" to a compatible library
warning #10420-D: For FRAM devices, at start up, the GPIO power-on default high-impedance mode needs to be disabled to activate previously configured port settings. This can be done by clearing the LOCKLPM5 bit in PM5CTL0 register.
remark #10371-D: (ULP 1.1) Detected no uses of low power mode state changing instructions
remark #10372-D: (ULP 4.1) Detected uninitialized Port A in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port B in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port C in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port D in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
remark #10372-D: (ULP 4.1) Detected uninitialized Port E in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
 
>> Compilation failure
makefile:143: recipe for target 'ZU_v7_FR5972.out' failed
 
 undefined first referenced
  symbol       in file     
 --------- ----------------
 MPUSEG    <whole-program> 
 __mpusam  <whole-program> 
 __mpuseg  <whole-program> 
 
error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "ZU_v7_FR5972.out" not built
gmake[1]: *** [ZU_v7_FR5972.out] Error 1
gmake: *** [all] Error 2
makefile:139: recipe for target 'all' failed

**** Build Finished ****

Thereis my mistake ?

  • Hello Alexander,
    not sure, what you're trying to do? Is it just testing a basic code example, as an initial test of your CCS installation?

    Best regards
    Peter
  • CCS 8.1.0 already tired me of constant incomprehensible mistakes.
    :-((

    I generally can not use MPU in my program, because of the wormhole of these constant errors, even when I allow the compiler to make "compler's own decision' in compilers own way - that's why I decided to check on a simple example who is to blame.

    I want to understand what's going on.
  • Hello Alexander,
    I am sorry for that. I hope we have a pretty easy solution for that.
    Please follow the following steps.
    1. setup a new workspace.
    2. Got to the Resource Explorer.
    3. Select "Software >> MSP430Ware - v.3.80.02.10 >> Devices >> MSP430FR5XX_6XX >> MSP430FR5972 >> Peripheral Examples >> Register Level
    4. There are two MPU code examples msp430fr6x7x_mpu_01.c and msp430fr6x7x_mpu_02.c. Click on one of them and then click in the right top corner on the symbol for import to IDE. This automatically creates the project with this example.

    I just tried it with the first one and it compiled without errors.

    Best regards
    Peter
  • I do this - msp430fr6x7x_mpu_02.c

    Result:

    ///

    **** Build of configuration Debug for project msp430fr6x7x_mpu_02.c ****
    
    "C:\\ti\\ccs8\\ccsv8\\utils\\bin\\gmake" -k -j 8 all -O 
     
    Building file: "../msp430fr6x7x_mpu_02.c"
    Invoking: MSP430 Compiler
    "C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmsp --code_model=small --data_model=small --use_hw_mpy=F5 --include_path="C:/ti/ccs8/ccsv8/ccs_base/msp430/include" --include_path="C:/alex/ti/workspace_v8/msp430fr6x7x_mpu_02.c" --include_path="C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --advice:power=all --advice:hw_config=all --define=__MSP430FR5972__ --define=_MPU_ENABLE -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --preproc_with_compile --preproc_dependency="msp430fr6x7x_mpu_02.d_raw"  "../msp430fr6x7x_mpu_02.c"
    "../msp430fr6x7x_mpu_02.c", line 90: remark #1528-D: (ULP 3.1) Detected flag polling using MPUSEG2IFG. Recommend using an interrupt combined with enter LPMx and ISR
    "../msp430fr6x7x_mpu_02.c", line 93: remark #1527-D: (ULP 2.1) Detected SW delay loop using __delay_cycles. Recommend using a timer module instead
    "../msp430fr6x7x_mpu_02.c", line 116: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
    Finished building: "../msp430fr6x7x_mpu_02.c"
     
    Building target: "msp430fr6x7x_mpu_02.c.out"
    Invoking: MSP430 Linker
    "C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmsp --code_model=small --data_model=small --use_hw_mpy=F5 --advice:power=all --advice:hw_config=all --define=__MSP430FR5972__ --define=_MPU_ENABLE -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 -z -m"msp430fr6x7x_mpu_02.c.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccs8/ccsv8/ccs_base/msp430/include" -i"C:/ti/ccs8/ccsv8/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccs8/ccsv8/ccs_base/msp430/lib/FR59xx" -i"C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/lib" -i"C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --priority --reread_libs --define=_MPU_ENABLE --diag_wrap=off --display_error_number --warn_sections --xml_link_info="msp430fr6x7x_mpu_02.c_linkInfo.xml" --use_hw_mpy=F5 --rom_model -o "msp430fr6x7x_mpu_02.c.out" "./msp430fr6x7x_mpu_02.obj" "../lnk_msp430fr5972.cmd"  -llibmpu_init.a -llibmath.a -llibc.a 
    <Linking>
    warning #10204-D: could not resolve index library "libmpu_init.a" to a compatible library
    warning #10204-D: could not resolve index library "libmath.a" to a compatible library
     
     undefined first referenced                                                                            
      symbol       in file                                                                                 
     --------- ----------------                                                                            
     MPUSEG    C:\ti\ccs8\ccsv8\tools\compiler\ti-cgt-msp430_18.1.3.LTS\lib\rts430_eabi.lib<mpu_init.c.obj>
     __mpusam  C:\ti\ccs8\ccsv8\tools\compiler\ti-cgt-msp430_18.1.3.LTS\lib\rts430_eabi.lib<mpu_init.c.obj>
     __mpuseg  C:\ti\ccs8\ccsv8\tools\compiler\ti-cgt-msp430_18.1.3.LTS\lib\rts430_eabi.lib<mpu_init.c.obj>
     
    remark #10371-D: (ULP 1.1) Detected no uses of low power mode state changing instructions
    error #10234-D: unresolved symbols remain
    remark #10372-D: (ULP 4.1) Detected uninitialized Port A in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port B in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port C in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port D in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port E in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
     
    >> Compilation failure
    makefile:143: recipe for target 'msp430fr6x7x_mpu_02.c.out' failed
    error #10010: errors encountered during linking; "msp430fr6x7x_mpu_02.c.out" not built
    gmake[1]: *** [msp430fr6x7x_mpu_02.c.out] Error 1
    makefile:139: recipe for target 'all' failed
    gmake: *** [all] Error 2
    
    **** Build Finished ****
    

  • I do not understand why in the settings of a new project is constantly exposed "mspx", because in all descriptions it is not for 16 bit architecture MSP430FR5972 and for 20 bit !
    Models of memory are always constantly exposed to "large", not for "small"! Large models is for ower(!) 64k FRAM(FLASH) !

    I do not consider myself a kettle, I understand that this should be corrected right away to get the working code, but there are other peoples who have not thoroughly understood the architecture of MSP430 ...
  • Hello Alexander,

    1. switch to TI v16.9.8.LTS compiler version
    2. turn off a MPU in Project Properties.

    5972 is based on 20 bits bus architecture so, in most cases, you should keep mspx on.
  • Hello Alexander,
    did you really use the import function? I just tried myself the code example and it compiles right away after importing it.

    **** Build of configuration Debug for project msp430fr6x7x_mpu_02.c ****

    "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 8 all -O

    Building file: "../msp430fr6x7x_mpu_02.c"
    Invoking: MSP430 Compiler
    "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmspx --data_model=restricted --use_hw_mpy=F5 --include_path="C:/ti/ccsv8/ccs_base/msp430/include" --include_path="C:/Users/a0197246/Daten/CCS8_1/E2E/FR5972/msp430fr6x7x_mpu_02.c" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --advice:power=all --advice:hw_config=all --define=__MSP430FR6972__ --define=_MPU_ENABLE -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --preproc_with_compile --preproc_dependency="msp430fr6x7x_mpu_02.d_raw" "../msp430fr6x7x_mpu_02.c"
    "../msp430fr6x7x_mpu_02.c", line 90: remark #1528-D: (ULP 3.1) Detected flag polling using MPUSEG2IFG. Recommend using an interrupt combined with enter LPMx and ISR
    "../msp430fr6x7x_mpu_02.c", line 93: remark #1527-D: (ULP 2.1) Detected SW delay loop using __delay_cycles. Recommend using a timer module instead
    "../msp430fr6x7x_mpu_02.c", line 116: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
    Finished building: "../msp430fr6x7x_mpu_02.c"

    Building target: "msp430fr6x7x_mpu_02.c.out"
    Invoking: MSP430 Linker
    "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmspx --data_model=restricted --use_hw_mpy=F5 --advice:power=all --advice:hw_config=all --define=__MSP430FR6972__ --define=_MPU_ENABLE -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 -z -m"msp430fr6x7x_mpu_02.c.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccsv8/ccs_base/msp430/include" -i"C:/ti/ccsv8/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv8/ccs_base/msp430/lib/FR59xx" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/lib" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --priority --reread_libs --define=_MPU_ENABLE --diag_wrap=off --display_error_number --warn_sections --xml_link_info="msp430fr6x7x_mpu_02.c_linkInfo.xml" --use_hw_mpy=F5 --rom_model -o "msp430fr6x7x_mpu_02.c.out" "./msp430fr6x7x_mpu_02.obj" "../lnk_msp430fr6972.cmd" -llibmpu_init.a -llibmath.a -llibc.a
    <Linking>
    remark #10371-D: (ULP 1.1) Detected no uses of low power mode state changing instructions
    remark #10372-D: (ULP 4.1) Detected uninitialized Port A in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port B in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port C in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port D in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port E in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    Finished building target: "msp430fr6x7x_mpu_02.c.out"


    **** Build Finished ****

    To me it looks like there is something wrong with your CCS installation. How did you get to the version you're using. Was it by updates of previous versions or is it a completely new installation? Could you please send us more information on the system you're using?

    Best regards
    Peter
  • 1) my Windows 7 (64). 

    2) Code Composer Studio Version: 8.1.0.00011   + All(!) updates, after "clear install" from ti.com 

    3) Installation details:

      Analysis Suite	4.1.0.201805141352	com.ti.dvt2.analysis.suite.feature.group	Texas Instruments
      C/C++ Development Tools	9.4.3.201802261533	org.eclipse.cdt.feature.group	Eclipse CDT
      C/C++ GCC Cross Compiler Support	9.4.3.201802261533	org.eclipse.cdt.build.crossgcc.feature.group	Eclipse CDT
      C/C++ Memory View Enhancements	9.4.3.201802261533	org.eclipse.cdt.debug.ui.memory.feature.group	Eclipse CDT
      C/C++ Remote Launch	9.4.3.201802261533	org.eclipse.cdt.launch.remote.feature.group	Eclipse CDT
      CCS and SAT Common Components Feature	8.1.0.201805221500	com.ti.tools.common.feature.group	Texas Instruments
      CCS Documentation	8.1.0.20180531	com.ti.ccstudio.doc.win32.feature.group	Texas Instruments
      CCS Launcher	8.1.0.20180404	com.ti.ccstudio.launcher.win32.feature.group	Texas Instruments
      CCS Utilities	1.0.0.20160210	com.ti.ccstudio.utils.cli.win32.feature.group	Texas Instruments
      CCStudio p2 Tool Feature	7.0.0.201611291427	com.ti.ccstudio.p2tool.feature.group	Texas Instruments
      Chromium Browser Feature	8.0.0.201805221500	com.ti.chromium.browser.feature.group	Texas Instruments
      Code Composer Studio Base Components	8.1.0.01300	com.ti.ccstudio.base.feature.group	Texas Instruments
      Code Composer Studio IDE Main Feature	8.1.0.201805221500	com.ti.ccstudio.idemain.feature.group	Texas Instruments
      Code Composer Studio IDE MSP430 Components	8.1.0.201805221500	com.ti.ccstudio.msp430.feature.group	Texas Instruments
      Code Composer Studio IDE Workflow	8.1.0.201805221500	com.ti.ccstudio.workflow.feature.group	Texas Instruments
      Compiler Tools On-line Documentation	1.1.5	com.ti.cgt.dmed.win32.feature.group	Texas Instruments
      Debug Server	8.1.0.1300	com.ti.ccstudio.debugserver.win32.feature.group	Texas Instruments
      Debug Server Flash	8.1.0.1300	com.ti.dsflash.win32.feature.group	Texas Instruments
      DVT - EnergyTrace	4.1.0.201805141352	com.ti.dvt.energytrace.feature.group	Texas Instruments
      DVT - Graph Visualization	4.1.0.201805141352	com.ti.dvt2.graph.visualization.feature.group	Texas Instruments
      DVT - Profiler Analysis Manager	4.1.0.201805141352	com.ti.dvt2.profileanalysismanager.feature.group	Texas Instruments
      DVT - Resource Explorer	4.1.0.201805141352	com.ti.dvt2.resource.explorer.feature.group	Texas Instruments
      DVT - System Analyzer	4.1.0.201805141352	com.ti.dvt2.uia.feature.group	Texas Instruments
      Eclipse Help System	2.2.103.v20180301-0715	org.eclipse.help.feature.group	Eclipse.org
      Eclipse Platform	4.7.3.M20180301-0715	org.eclipse.platform.ide	Eclipse.org
      Equinox p2, Discovery UI support	1.1.1.v20170906-1259	org.eclipse.equinox.p2.discovery.feature.feature.group	Eclipse.org - Equinox
      Equinox p2, Provisioning for IDEs.	2.3.2.v20171108-1343	org.eclipse.equinox.p2.user.ui.feature.group	Eclipse.org - Equinox
      GCC MSP430 Compiler Tools	7.3.1.24	com.ti.gcc.msp430.win32.feature.group	Texas Instruments
      GCC MSP430 tool-chain	8.2.0	com.ti.msp430.gcc_support.feature.group	Texas Instruments
      GEF (MVC)	3.11.0.201606061308	org.eclipse.gef.feature.group	Eclipse GEF
      Git integration for Eclipse	4.9.2.201712150930-r	org.eclipse.egit.feature.group	Eclipse EGit
      Graphical Modeling Framework (GMF) Runtime Third-Party Components	1.11.0.201706061437	org.eclipse.gmf.runtime.thirdparty.feature.group	Eclipse Modeling Project
      GUI Composer Backplane Feature	8.1.0.201805221500	com.ti.gc.backplane.feature.group	Texas Instruments
      GUI Composer Program Model Feature	8.1.0.201805221500	com.ti.gc.pm.feature.group	Texas Instruments
      IDE - Debug Server Integration Feature	8.1.0.201805221500	com.ti.debug.server.feature.group	Texas Instruments
      Image Analyzer	4.1.0.201805141352	com.ti.dvt2.via.ccs.feature.group	Texas Instruments
      LWInstaller	8.1.0.00011	com.ti.ccstudio.installer.win32.feature.group	Texas Instruments
      Marketplace Client	1.6.4.v20180214-1810	org.eclipse.epp.mpc.feature.group	Eclipse Marketplace Client
      MSP430 Compiler Help	18.1.0.20180221225502	com.ti.msp430.18.1.help.feature.group	Texas Instruments
      MSP430 Compiler Tools	18.1.3	com.ti.cgt.msp430.17.win32.feature.group	Texas Instruments
      Node.js	8.11.1	com.ti.ccstudio.nodejs.win32.feature.group	Texas Instruments
      p2appf	8.1.0.201805221500	com.ti.ccstudio.p2appf.feature.group	Texas Instruments
      Pin Mux	4.0.1470	com.ti.ccstudio.pinmux.win32.feature.group	Texas Instruments
      Remote System Explorer End-User Runtime	3.7.3.201704251225	org.eclipse.rse.feature.group	Eclipse TM Project
      ROV	4.1.0.201805141352	com.ti.dvt2.rov.feature.group	Texas Instruments
      RTSC/XDCtools (IDE Client)	3.50.7.20	org.eclipse.rtsc.xdctools.product.ui.feature.group	Texas Instruments
      RTSC/XDCtools (Target Runtime Support)	3.50.7.20	org.eclipse.rtsc.xdctools.product_3.50.7.20.feature.group	Texas Instruments
      RTSC/XDCtools (Target Runtime Support)	3.32.2.25	org.eclipse.rtsc.xdctools.product_3.32.2.25.feature.group	Texas Instruments
      RXTX End-User Runtime	2.1.8.0_201606281300	gnu.io.rxtx.feature.group	RXTX.org
      Sys Config	1.0.296	com.ti.ccstudio.sysconfig.feature.group	Texas Instruments
      TargetDB Default Props	8.1.0.N201805221500	com.ti.ccstudio.targetdb.props.default.win32.feature.group	Texas Instruments
      TI Cloud Agent	0.5.1463	com.ti.ccstudio.cloudagent.win32.feature.group	Texas Instruments
      TI MSP430 tool-chain	8.2.0	com.ti.msp430.build_debug.feature.group	Texas Instruments
      TI Target Content	1.0.0.201805221539	com.ti.targetcontent.feature.group	Texas Instruments
      TIREX Desktop	3.6.9.201805241207	com.ti.tirex.feature.group	Texas Instruments
      TM Terminal	4.3.0.201706140544	org.eclipse.tm.terminal.feature.feature.group	Eclipse.org - Target Management
      TM Terminal Serial Connector Extensions	4.3.0.201706140544	org.eclipse.tm.terminal.connector.cdtserial.feature.feature.group	Eclipse.org - Target Management
      XDCtools Core Update Feature	3.32.2.25	com.ti.xdctools_3_32.update.feature.group	Texas Instruments

    ----------------
    My new try.

    // ----
    
    ...
    #include <msp430fr5972.h>
    ...
    #pragma SET_CODE_SECTION(".mpu")
    extern void lcd_init(void);
    extern void LCD_print(void);
    extern void LCD_print_init(void);
    extern void lcd_clear(void);
    extern void lcd_gotoxy(char, char);
    extern int _system_pre_init(void);
    extern int main (void);
    #pragma SET_CODE_SECTION()
    
    ...
    
    // Configure MPU
    MPUCTL0 = MPUPW;           // Write PWD to access MPU registers
    MPUSEGB1 = 0xA006;         // B1 = 0x; B2 = 0x --- from .mpu SET_CODE_SECTION(".mpu")
    MPUSEGB2 = 0xA006+0x474C;  // Borders are assigned to segments
    
    // Segment 1 - Execute, Read
    // Segment 2 - Violation, Execute, Read
    // Segment 3 - Execute, Read
    MPUSAM = MPUSEG1RE | MPUSEG1XE |
    MPUSEG2VS | MPUSEG2RE | MPUSEG2XE |
    MPUSEG3RE | MPUSEG3XE |
    MPUSEGIRE | MPUSEGIXE | MPUSEGIWE;
    MPUCTL0 = MPUPW | MPUENA; // Enable MPU protection
    ...
    // ------ from my  .map file:
    //   .mpu 0 0000a006 0000474c 
    // 0000a006 00001d12 main.obj (.mpu:main)
    // 0000bd18 00001bd0 main.obj (.mpu:LCD_print)
    // 0000d8e8 00000996 main.obj (.mpu:LCD_print_init)
    // 0000e27e 000003a4 main.obj (.mpu:_system_pre_init)
    // 0000e622 000000e0 main.obj (.mpu:lcd_init)
    // 0000e702 00000050 main.obj (.mpu:lcd_gotoxy)
    // .......
    
    

    After compile:

    ...........

    **** Build of configuration Release for project ZU_v7_FR5972 ****
    
    "C:\\ti\\ccs8\\ccsv8\\utils\\bin\\gmake" -k -j 8 all -O 
     
    Building file: "../main.c"
    Invoking: MSP430 Compiler
    "C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmsp --code_model=small --data_model=small -O4 --opt_for_speed=5 --use_hw_mpy=32 --include_path="C:/ti/ccs8/ccsv8/ccs_base/msp430/include" --include_path="C:/alex/ti/workspace_v8/ZU_v7_FR5972" --include_path="C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --advice:hw_config="all" --define=__MSP430FR5972__ --symdebug:none --printf_support=full --diag_warning=225 --diag_wrap=off --display_error_number --ramfunc=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --disable_interrupts_around_hw_mpy=off --preproc_with_compile --preproc_dependency="main.d_raw"  "../main.c"
     
    >> Compilation failure
    subdir_rules.mk:9: recipe for target 'main.obj' failed
    "../main.c", line 71: warning #78-D: this declaration has no storage class or type specifier
    "../main.c", line 71: error #148: declaration is incompatible with "volatile unsigned int MPUCTL0" (declared at line 2375 of "C:/ti/ccs8/ccsv8/ccs_base/msp430/include/msp430fr5972.h")
    "../main.c", line 72: warning #78-D: this declaration has no storage class or type specifier
    "../main.c", line 72: error #148: declaration is incompatible with "volatile unsigned int MPUSEGB1" (declared at line 2384 of "C:/ti/ccs8/ccsv8/ccs_base/msp430/include/msp430fr5972.h")
    "../main.c", line 73: warning #78-D: this declaration has no storage class or type specifier
    "../main.c", line 73: error #148: declaration is incompatible with "volatile unsigned int MPUSEGB2" (declared at line 2381 of "C:/ti/ccs8/ccsv8/ccs_base/msp430/include/msp430fr5972.h")
    "../main.c", line 73: warning #69-D: integer conversion resulted in a change of sign
    "../main.c", line 78: warning #78-D: this declaration has no storage class or type specifier
    "../main.c", line 78: error #148: declaration is incompatible with "volatile unsigned int MPUSAM" (declared at line 2387 of "C:/ti/ccs8/ccsv8/ccs_base/msp430/include/msp430fr5972.h")
    "../main.c", line 82: warning #78-D: this declaration has no storage class or type specifier
    "../main.c", line 82: error #150: variable "MPUCTL0" has already been initialized
    "../main.c", line 2802: warning #112-D: statement is unreachable
    5 errors detected in the compilation of "../main.c".
    gmake: *** [main.obj] Error 1
    gmake: Target 'all' not remade because of errors.
    
    **** Build Finished ****
    

  • Whot is correct for MSP430FR5972 ?
    1) -vmsp --code_model=small --data_model=small
    or
    2) -vmspx --code_model=small --data_model=small
  •  Hello Alexander,

    I am sorry for these inconveniences.

    The correct settings, please see here the screen shot of my project:

    Thank you for the information on your system. You have the same CCS version as me. Win7 should be fine too, though I am using 10, but that should not matter.

    I am wondering whether something went wrong with the installation. Could you please import any other code example from the Explorer and try to compile that one, just to check whether these compile, or you get similar issues with them.

    Best regards

    Peter

  • Hi,

    have you been able to compile msp430fr6x7x_mpu_02.c?
  • "../main.c", line 71: warning #78-D: this declaration has no storage class or type specifier

    Looks to me that it is linked to a linker file and #pragma SET_CODE_SECTION() usage.

  • Hello Alexander,
    Looking deeper into your CDT Build Console printout I see some fundamental differences compared with mine
    1. "C:\\ti\\ccs8\\ccsv8\\utils\\bin\\gmake" -k -j 8 all -O on your side, which means to me, you have not installed CCS into the default directory. This can sometimes generate issues, and maybe is already one part of the issue. Please see in comparison my installation path "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 8 all –O
    2. Building file: "../main.c"
    Invoking: MSP430 Compiler
    "C:/ti/ccs8/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmsp --code_model=small --data_model=small -O4 on your side.
    On my side
    Invoking: MSP430 Compiler
    "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmspx --data_model=restricted --use_hw_mpy=F5 --include_path="C:/ti/ccsv8/ccs_base/msp430/include" --include_path="C:/Users/a0197246/Daten/CCS8_1/E2E/FR5972/msp430fr6x7x_mpu_02.c" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --advice:power=all --advice:hw_config=all --define=__MSP430FR6972__ --define=_MPU_ENABLE -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --preproc_with_compile --preproc_dependency="msp430fr6x7x_mpu_02.d_raw" "../msp430fr6x7x_mpu_02.c"

    Again this looks fundamentally different to mine. Which sort of puzzles me, as when importing a project from us, not only the source, but of course also the project settings should be copied from our original project, means they should be the same. This is not the case on your side. So to me it looks like the import did not work, or the project has not been created by import, but setting it up manually, and then just copying the source code into the manually created project. Which in many cases does not work out, as one can easily miss some of the essential settings.

    So my suggestion would be, please create the project by importing the code example from the TI Explorer to your local workspace. If this still results in same issues, please try importing any other of the code examples, as suggested in my previous post. If this still fails, then I’d recommend removing everything related to the current CCS installation and re-install CCS in the default directory.

    Best regards
    Peter
  • Dear Peter.
    I may not even speak fluent English, but I can read smart books and tutorials from TI
    Please read:
    MSP430 Optimizing C_C++ Compiler v18.1.0.LTS ---- slau132r .pdf

    It is written that MSP430 has a 64 kilobyte memory model with 16 bits of address, it means (and so it is written in the book) that it is necessary to use msp instead of mspx (as it is written) and the smal model code and the smal model of the data.

    My brains are already boiling, from all these inconsistencies.
    I wrote and debugged my program for Atmel, I licked it for 3 years, and now I've read the books, and rewrote the program under MSP430.

    The first finished device in which I downloaded the program - works fine.
    All tests passed, all hardware checked 10 times. There are no errors.

    Now I solder a batch of devices, with exactly the same program as the first device - and .......

    Miracles have begun.
    1) I took an example with a JTAG password, inserted it into my program and got a "brick" that works but does not want to accept the password. All my attempts to understand the three lines of code did not lead to anything. Even an example in itself from three lines leads to a "brick" ...

    2) I want to secure the microchip from distorting the code, using MPU, I get a bunch of mats from the compiler, even on an example of 10 lines, from the manual.

    3) I delete all the references from Windows about the compo studio code, clean the registry, check, reboot the computer, check again - everything is clean.
    I put (already the third time I do so) anew the code of the studio composer - there are no errors. I take an example - compile - and again get a mountain of errors. :(

    I do not understand what's going on.

    I worked with CVAVR Studio, I did not see such chaos there....
    I reread the mountain of manuals from TI. I found and downloaded lectures on the architecture of MSP430 - but it does not help me.
  • Alexander,
    as stated, I am absolutely sorry about all the valid points of yours. Still we have to find a way to solve these issues. Do I understand your 3rd point correctly, in the sense, that you have tried an other code example, than the MPU ones, importing and compiling and still get a number of errors?

    Best regards
    Peter
  • Dear Alexander,

    you have written:
    It is written that MSP430 has a 64 kilobyte memory model with 16 bits of address, it means (and so it is written in the book) that it is necessary to use msp instead of mspx (as it is written) and the smal model code and the smal model of the data.

    Your MPU datasheet overpasses all the other documents regarding this particular device features.
    I already told you that your MCU has 20 bits address architecture.

    Your first device works fine.
    Something wrong happened later and you did that unintentionally.

    I do not see that you include:
    #include <msp430.h>
    If you do not include msp430.h you do not define an architecture:
    #define __msp430

    Do try to solve all issues step by step.
    Skip the password, skip MPU protection.

  • Hello Alexander,
    have you been able to resolve the compile problems? What is the status on your side? Do you still need help on this?

    Best regards
    Peter
  • I found out everything, the problem was not in my program.

    The very first "from scratch" installation CCS 8.1.0 does (collects) my program as it should work.
    I already got gray hair, trying to understand why in the switch - case construction that I worked for 3 years and did not change, suddenly the first three conditions were executed, and then it is not executed.
    and no "build clean project" does not help ...
    For my 30 years of programming, I see for the first time that the compiler for me decides to change the logic of the work(!) of my program!
    This is madness !

    I disconnected all the compression, all the optimization, I put all the optimization, I wiped all the temporary files with my hands - it did not help.

    I thought that in the chip I did not wipe out all the memory and data in the second third time of rewriting - no, it does not help.

    I would be grateful to you for helping me solve the problem of how to compile my project "as new newly created" after any modification of the file main.c

  • Hello Alexander,

    I am sorry about the issues you're facing. We will do our best to help you solving the problems. I see basically two possibilities. Either something in the project settings got corrupted, and maybe is not possible to be cleaned manually, which of course should not be the case, but we have to take all potential problems into account, or the CCS installation is damaged.

    For the 2nd one, that's why I asked whether you're able to import and compile any of the other FR5972 code examples. It's of course not a full coverage test, but if you can compile other than the MPU code examples, that would prove basic functionality of your CCS installation. If the other examples do not work too, I'd recommend to clean your PC from all CCS IDE related files uninstalling and cleaning manually if necessary all directories, and then re-install the latest version.

    For the first one, there would be the option to share your project with me privately, and I could try to compile the project on my side. To share resources with me privately, you have to add me to your friend list and then you could share data with me privately.

    Please let me know, which path you'd like to take.

    Best regards

    Peter

  • Alexander,

    I can help you in a similar way as that offered by Peter.
    However, I am not TI employee and you would need to decide what to share with me.
    I do not have MSP-TS430PM64F, MSP430FR5972 either.
    I have MSP-EXP430FR6989, so there is a chance that my MCU has all features you utilize in your project.

    I would recommend to start we a new workspace, to import an appropriate project example and step by step add features to the point of failure.

    My time zone is GMT+1 and +1 summer time.
  • Peter

    1) After a "clean" CCS 8.1.0 installation, I can compile the examples.
    All examples.
    and can change the parameters - MPU IPE.
    and can change the parameters - "optimize"

    2) MSP430FR5969 (board) the same as MSP430FR5972 on the settings, except for the operation of ports (I have my own settings, I checked them and everything works).

    The problem is that without changing my program code in the main file, I compile it, I get, for example, 40933 bytes of the program length.
    I load, everything works for the first time - as I wrote (I do not write complex constructions, my code is read and written in the simple style of "Kernigan and Richie")

    I make changes, just a couple of lines, or five lines, an addition.
    I compile the "clean" project, then write it down - and again I see 40933 bytes of the program! This is insane ...
    I understand that there may be rounding out a whole block.
    but the program after download, which WORKED, now after the second download does not work anymore as I wrote.
    No compiler errors.
    No linker errors.
    I only have two warnings, 148K bytes of text code, and this is a warning about checking the FRAM at 8MHz, but I'm not working above 8MHz.

    It seems that the compiler decides what has changed and what is not in my program.
    All attempts to force to reread all the files and create anew the entire project - do not work.
    The compiler shows the work, and even restores the object files deleted manually. It seems that there is some cache where he stores what he has already collected, and instead of my new line of code - he gets the old one, which he has already produced, and inserts it into a new project.
    There are no errors.
    Windows 7 which I have only those programs that are needed for the work, no Games, nothing superfluous, everything installed is checked and all unnecessary is cleaned in the registry.
    I'm sure of it.

    Now my Compilers flags:
    -vmspx --code_model=small --data_model=small -O4 --opt_for_speed=5 --use_hw_mpy=F5 --include_path="C:/ti/ccsv8/ccs_base/msp430/include" --include_path="C:/alex/ti/workspace_v8/ZU_v7_FR5972" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --advice:hw_config="all" --define=__MSP430FR5972__ --define=_MPU_ENABLE --symdebug:none --printf_support=full --diag_warning=225 --diag_wrap=off --display_error_number --gen_data_subsections=on --ramfunc=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --program_level_compile --call_assumptions=0 --disable_interrupts_around_hw_mpy=on --multithread --remove_hooks_when_inlining

    Linker flags:
    -vmspx --code_model=small --data_model=small -O4 --opt_for_speed=5 --use_hw_mpy=F5 --advice:hw_config="all" --define=__MSP430FR5972__ --define=_MPU_ENABLE --symdebug:none --printf_support=full --diag_warning=225 --diag_wrap=off --display_error_number --gen_data_subsections=on --ramfunc=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --program_level_compile --call_assumptions=0 --disable_interrupts_around_hw_mpy=on --multithread --remove_hooks_when_inlining -z -m"ZU_v7_FR5972.map" --heap_size=160 --stack_size=400 --cinit_hold_wdt=on -i"C:/ti/ccsv8/ccs_base/msp430/include" -i"C:/ti/ccsv8/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv8/ccs_base/msp430/lib/FR59xx" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/lib" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --priority --reread_libs --define=_MPU_ENABLE --diag_wrap=off --display_error_number --warn_sections --absolute_exe --xml_link_info="ZU_v7_FR5972_linkInfo.xml" --make_static --use_hw_mpy=F5 --cinit_compression=off --copy_compression=off --rom_model

    ====== "On connect erase main,information, and IP protected area"

    === "Erase main,information, and IP protected area"

    if I change. optimization settings, stack size, the resulting code size varies, but the program does not work the first time, not as I wrote.

  • Hello Alexander,
    many thanks for the additional information.
    Based on this a few comments, where you could look at.
    addressing the point of compiler potentially not accepting made changes:
    A) When you have a newly setup project and change the code for the first time and restart the debugger, there should a window come up, indicating a change of the source file, asking, whether you would like to save it and including a check box where you can click "always save before ..." .I personally always enable this, as it makes sure the changes are stored, thus even if the compiler crashes or whatever happens the changes are stored and applied.
    B) In the general options of the respective project in the menu General, you can see the Configuration. There can be multiple configurations, where you can specify e.g. which source files are being used. You could have e.g. a Debug Configuration, where you changing and debugging, and a Release Configuration, where e.g. the finalized instance of your project could be. Probably this should be clean on your side, if you have setup the project newly from scratch, but just to make sure, please check on this one.
    C) Sometimes it helps when you select from the "Project" Pull-Down menu the point Clean. In this case the entire project should be cleaned, means all Compiler, Linker etc. generated sources should be trashed and rebuild.

    To check whether the Compiler is applying the changes you're making there I would see following options:
    A) After executing the download, before starting the code execution you can go to the pull-down menu "View" and select "Disassembly". This opens a new window in parallel to the one showing only the C-Code, showing not only the C-Code but also the translation to assembler and the memory addresses, where the code is being stored. This way you can check, whether the code lines added are really placed in FRAM, and where.
    B) In a similar way, you can go to "VIew" and "Memory Browser" on one hand in this window you can check memory locations and their actual content in hex code, on the other hand you can also store the memory content in a .txt file. This way you could store the memory of the first compile and download, and compare it with the second compile and download for differences.

    Please try to perform such a comparison. There are free compare tools available, which can help you indicating differences of two files.
    The other thing, which might be happening, as you're working with the MPU, is that on first compile, you program the device with some memory protection code, and then have difficulties to erase certain locations, protected by the MPU, which then causes issues with the updated larger code, where potentially some portions are blocked by the MPU. But this should be detectable by the above compare methods.
    I hope this helps you getting a step towards resolution of the problem.

    Best regards
    Peter
  • Alexander,

    I missed that you have switched to CCS 8.1.0 and I moved to 8.0.0 .

    However I have created the empty main.c project called TEST_5972_v01
    and I have compiled it without errors.

    #include <msp430.h> 
    
    
    /**
     * main.c
     */
    int main(void)
    {
    	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
    	
    	return 0;
    }
    

    and console output:

    **** Build of configuration Debug for project TEST_5972_v01 ****
    
    "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 2 all -O 
     
    Building file: "../main.c"
    Invoking: MSP430 Compiler
    "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/bin/cl430" -vmspx --data_model=restricted --use_hw_mpy=F5 --include_path="C:/ti/ccsv8/ccs_base/msp430/include" --include_path="C:/TI_Trash/CCS80/TEST_5972_v01" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/include" --advice:power=all --advice:hw_config=all --define=__MSP430FR5972__ --define=_MPU_ENABLE -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --preproc_with_compile --preproc_dependency="main.d_raw"  "../main.c"
    Finished building: "../main.c"
     
    Building target: "TEST_5972_v01.out"
    Invoking: MSP430 Linker
    "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/bin/cl430" -vmspx --data_model=restricted --use_hw_mpy=F5 --advice:power=all --advice:hw_config=all --define=__MSP430FR5972__ --define=_MPU_ENABLE -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 -z -m"TEST_5972_v01.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccsv8/ccs_base/msp430/include" -i"C:/ti/ccsv8/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv8/ccs_base/msp430/lib/FR59xx" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/lib" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/include" --priority --reread_libs --define=_MPU_ENABLE --diag_wrap=off --display_error_number --warn_sections --xml_link_info="TEST_5972_v01_linkInfo.xml" --use_hw_mpy=F5 --rom_model -o "TEST_5972_v01.out" "./main.obj" "../lnk_msp430fr5972.cmd"  -llibmpu_init.a -llibmath.a -llibc.a 
    <Linking>
    remark #10371-D: (ULP 1.1) Detected no uses of low power mode state changing instructions
    warning #10420-D: For FRAM devices, at start up, the GPIO power-on default high-impedance mode needs to be disabled to activate previously configured port settings. This can be done by clearing the LOCKLPM5 bit in PM5CTL0 register.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port A in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port B in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port C in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port D in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port E in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    Finished building target: "TEST_5972_v01.out"
     
    
    **** Build Finished ****
    

    Your compilation has failed because you have used non standard Processor Options.

    I have already told you that your MCU has 20 bits architecture.
    There are no math libs compatible with your memory model.

    Valid setting below:

  • UPS,

    scrolling this post up and down,
    I did a mistake.

    My last answer is to your original question.
    Irritating, sorry!
  • to Peter

    problem now is:

    ....code............

     if( ++SW_kn2 > 20 ) SW_kn2=0;
                  switch ( SW_kn2 ) {
                   case 0 : Zar_regim=20; SW_Regim=2; break;
                   case 1 : Zar_regim=3;  SW_Regim=3; break;
                   case 2 : Zar_regim=21; SW_Regim=3; break;
                   case 3 : SW_kn2=6; Zar_regim=52; SW_Regim=5; break;
                   case 4 : if( Pin9bit4==1 ) {Zar_regim=23; SW_Regim=2;}
                   case 5 : if( Pin9bit4==1 ) {Zar_regim=24; SW_Regim=2;}
                   case 6 : Zar_regim=4;  SW_Regim=4; SW_kn2=11; break;
                   case 7 : if( Pin9bit4==1 ) {Zar_regim=41; SW_Regim=4;} break;
                   case 8 : if( Pin9bit4==1 ) {if(z==6 || z==7) { Zar_regim=44; SW_Regim=4;} else { Zar_regim=42; SW_Regim=4;}} break;
                   case 9 : if( Pin9bit4==1 ) {if(z==6 || z==7) { Zar_regim=44; SW_Regim=4;} else { Zar_regim=42; SW_Regim=4;}} break;
                   case 10 : if( Pin9bit4==1 ) {Zar_regim=44; SW_Regim=4;} break;
                   case 11 : if(z==6 || z==7) {Zar_regim=54; SW_Regim=5;} else {Zar_regim=52; SW_Regim=5;} break;
                   case 12 : if(z==6 || z==7) {Zar_regim=54; SW_Regim=5;} else {Zar_regim=53; SW_Regim=5;} break;
                   case 13 : Zar_regim=54; SW_Regim=5; break;
                   case 14 : Zar_regim=20; SW_Regim=2; break;
                   case 15 : Zar_regim=7; SW_Regim=7; break;
                   case 16 : Zar_regim=20; SW_Regim=2; break;
                   case 17 : Zar_regim=20; SW_Regim=2; break;
                   case 18 : Zar_regim=20; SW_Regim=2; break;
                   case 19 : Zar_regim=8; SW_Regim=2; break; 
                   case 20 : Zar_regim=9; SW_Regim=2; break; 
                   default : __never_executed();
                   }

    -----------------

    This is a piece of code that I wrote over three years ago, and it 100% works on Atmel exactly as it is written.
    Now this code (piece) works all at the first compilation, and at the subsequent works ONLY the case 0-1-2, then it comes back to the case 0 and again 1-2-0-1-2...

    the code before this piece works.
    code immediately after this piece - also works.

    I changed the size of the stack - it does not help.
    I changed various ways of optimization - it does not help.

    Clean build wrote me:

    **** Build of configuration Release for project ZU_v7_FR5972 ****
    
    "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 8 all -O 
     
    Building files: "../main.c"
    Invoking: MSP430 Compiler
    "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmspx --code_model=small --data_model=small -O2 --opt_for_speed=4 --use_hw_mpy=F5 --include_path="C:/ti/ccsv8/ccs_base/msp430/include" --include_path="C:/alex/ti/workspace_v8/ZU_v7_FR5972" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --advice:hw_config="all" --define=__MSP430FR5972__ --define=_MPU_ENABLE --symdebug:none --printf_support=full --diag_warning=225 --diag_wrap=off --display_error_number --gen_data_subsections=on --ramfunc=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --program_level_compile --call_assumptions=0 --disable_interrupts_around_hw_mpy=on --multithread --remove_hooks_when_inlining  "../main.c"  
    <Optimizing>
    <Generating>
    <Assembling>
    "../main.c", line 2734: warning #112-D: statement is unreachable
    Finished building: "../main.c"
     
    Building target: "ZU_v7_FR5972.out"
    Invoking: MSP430 Linker
    "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmspx --code_model=small --data_model=small -O2 --opt_for_speed=4 --use_hw_mpy=F5 --advice:hw_config="all" --define=__MSP430FR5972__ --define=_MPU_ENABLE --symdebug:none --printf_support=full --diag_warning=225 --diag_wrap=off --display_error_number --gen_data_subsections=on --ramfunc=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --program_level_compile --call_assumptions=0 --disable_interrupts_around_hw_mpy=on --multithread --remove_hooks_when_inlining -z -m"ZU_v7_FR5972.map" --heap_size=160 --stack_size=400 --cinit_hold_wdt=on -i"C:/ti/ccsv8/ccs_base/msp430/include" -i"C:/ti/ccsv8/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv8/ccs_base/msp430/lib/FR59xx" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/lib" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --priority --reread_libs --define=_MPU_ENABLE --diag_wrap=off --display_error_number --warn_sections --absolute_exe --xml_link_info="ZU_v7_FR5972_linkInfo.xml" --make_static --use_hw_mpy=F5 --cinit_compression=off --copy_compression=off --rom_model -o "ZU_v7_FR5972.out" "main.obj"  "../lnk_msp430fr5972.cmd"  -llibmath.a -llibmpu_init.a -llibc.a 
    <Linking>
    warning #10421-D: For FRAM devices running at higher than 8MHz, FRAM waitstate needs to be configured accordingly.
    Finished building target: "ZU_v7_FR5972.out"
     
    
    **** Build Finished ****
    

    ----  line 2734: warning #112-D: statement is unreachable --- is a " return 0;---

    int main(void)

    {

    while (1) {

    ...

    }

    return 0;

    }

  • Tomasz

    Your advice does not help me.
    I made the settings:
    mspx
    large
    restricted
    globals

    all the same does not work further case 0-1-2 (see my previous message)

    I'm looking carefully into the settings - debug and release are compiled in different ways,
    but the result is one: case 0-1-2-0-1-2... :-((

    **** Build of configuration Release for project ZU_v7_FR5972 ****
    
    "C:\\ti\\ccsv8\\utils\\bin\\gmake" -k -j 8 all -O 
     
    Building files: "../main.c"
    Invoking: MSP430 Compiler
    "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmspx --code_model=large --data_model=restricted -O2 --opt_for_speed=4 --use_hw_mpy=F5 --include_path="C:/ti/ccsv8/ccs_base/msp430/include" --include_path="C:/alex/ti/workspace_v8/ZU_v7_FR5972" --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --advice:hw_config="all" --define=__MSP430FR5972__ --define=_MPU_ENABLE --symdebug:none --printf_support=full --diag_warning=225 --diag_wrap=off --display_error_number --gen_data_subsections=on --ramfunc=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --program_level_compile --call_assumptions=0 --disable_interrupts_around_hw_mpy=on --multithread --remove_hooks_when_inlining  "../main.c"  
    <Optimizing>
    <Generating>
    <Assembling>
    "../main.c", line 2734: warning #112-D: statement is unreachable
    Finished building: "../main.c"
     
    Building target: "ZU_v7_FR5972.out"
    Invoking: MSP430 Linker
    "C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/bin/cl430" -vmspx --code_model=large --data_model=restricted -O2 --opt_for_speed=4 --use_hw_mpy=F5 --advice:hw_config="all" --define=__MSP430FR5972__ --define=_MPU_ENABLE --symdebug:none --printf_support=full --diag_warning=225 --diag_wrap=off --display_error_number --gen_data_subsections=on --ramfunc=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --program_level_compile --call_assumptions=0 --disable_interrupts_around_hw_mpy=on --multithread --remove_hooks_when_inlining -z -m"ZU_v7_FR5972.map" --heap_size=160 --stack_size=400 --cinit_hold_wdt=on -i"C:/ti/ccsv8/ccs_base/msp430/include" -i"C:/ti/ccsv8/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv8/ccs_base/msp430/lib/FR59xx" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/lib" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.3.LTS/include" --priority --reread_libs --define=_MPU_ENABLE --diag_wrap=off --display_error_number --warn_sections --absolute_exe --xml_link_info="ZU_v7_FR5972_linkInfo.xml" --make_static --use_hw_mpy=F5 --cinit_compression=off --copy_compression=off --rom_model -o "ZU_v7_FR5972.out" "main.obj"  "../lnk_msp430fr5972.cmd"  -llibmath.a -llibmpu_init.a -llibc.a 
    <Linking>
    warning #10421-D: For FRAM devices running at higher than 8MHz, FRAM waitstate needs to be configured accordingly.
    Finished building target: "ZU_v7_FR5972.out"
     
    
    **** Build Finished ****
    

    I see in .map file after "large+restricted":

    .text.2    0    00010000    00004000     
                      00010000    000016c4     main.obj (.text:main)
                      000116c4    00001324     main.obj (.text:LCD_print)
                      000129e8    00000868     main.obj (.text:LCD_print_init)
                      00013250    000004dc     main.obj (.text:Rint_measure)
                      0001372c    00000466     rts430x_lc_rd_eabi.lib : frcdivd.c.obj (.text:__TI_frcdivd)
                      00013b92    000003e4     main.obj (.text:_system_pre_init)
                      00013f76    00000080     rts430x_lc_rd_eabi.lib : ltoa.c.obj (.text:ltoa)
                      00013ff6    0000000a                            : abs.c.obj (.text:abs)
    
    

    13ff6   == 81910 !!!

    81910 is greater then 64000 bytes of FRAM im MSP430FR5972 !!!

    Tomasz - why do you give me harmful and wrong advice?
    The instructions clearly state that the model should be smal!

  • Hello Alexander,
    many thanks for the additional testing and information. I'll try to generate a small project example, implementing your If / case piece of code, and see what happens. I'll come back to you as soon as possible.

    Best regards
    Peter
  • Alexander,

    I have already said SORRY!
    after I realized yesterday that I have unintentionally replayed to your initial question.

    I repeat, you use 20 bits addressing architecture!

    13ff6 == 81910 !!!

    The above means that a linker file or something in a tool chain is wrong.

    You: Tomasz - why do you give me harmful and wrong advice?
    Nothing wrong on my site.
    Three days ago Peter gave you the memory model settings for your MCU:



    You: The instructions clearly state that the model should be small!
    Which instructions?

    Three days ago I recommend you to use TI v16.9.8.LTS.
    Did you tried with this compiler version?
    Do you know that probably all TI-RTOS examples do not work with v18.x.x?

    I do believe that your issue is related to MPU usage and maybe to a compiler version.
    From the very begin there were some wrong assumptions, settings and frustrating errors.

    Alexander, I am trying to help.

  • Hello Alexander,
    to comment briefly on the discussion about the memory model. Some MSP430 devices might not be visible as 20bit architectures, as not having a program memory space, which would require a 20bit address range. Nevertheless in some cases devices still have a 20bit addressing bus, as they have been derived from derivatives with larger memory models.
    For these reasons, it is a good practice, to start off projects based on one of TI's examples in the TI Resource Explorer, as with the import function all the related settings are configured properly, and one does not have to read through documentation, to identify all the device specific parameters.
    Just for information, the type of the CPU of a device is e,g, visible in the device datasheet in the block diagram of the respective device. In case of the FR5972 the block diagram shows CPUXV2 incl. 16 Registers. CPUX means 20bit architecture.

    Now to your If/case code. To enable me generating a code as close as possible to your, could you please post the variable definitions for this section?
    Another question related to that code portion. You're using in case 4 the expression Pin9bit4==1. Is the Pin9bit4 just a variable, or is it in some way related to testing of GPIO register content, like if input at P9.4 is high then.....? Please give me a bit more details on that.
    Many thanks in advance.

    Best regards
    Peter
  • to Tomasz

    after the spent day on the proceedings "how IT works", I can say that for MSP430FR5972 the only possible
    configuration (ONLY ! working! configuration!) is:
    -vmspx
    --code_model=large
    --data_model=restricted
    --near_data=globals
    .

    In this case, the linker makes two pieces of code - one completely clogs the top part (16535?) Of the code (100% use)

    and the second part in the lower 48000kbytes of memory.


    To the one who wrote the document:
    "MSP430 Optimizing C_C++ Compiler v18.1.0.LTS" ( slau132r )
    my congratulations! The document is lying. :-((
    I do not use TI-RTOS in my programs. At all.
    assumptions = 0 in my prog.

    All the same, different compilations (in time) spoil the code and work unpredictably (an example of a piece of code I cited earlier)

    in this code for one compilation only 0-1-2-0-1-2 works ... when repeated it works all 20 labels .
    I have no more ideas what to do ...

    I do not understand why the compiler is trying to rewrite the logic of my code?
    the variable SW_kn2 is nowhere else in the program (I've tested 10 times) except this place (++SW_kn2) is not modified and does not change!

  • to Peter

    Many thanks to you for trying to help me.

    you will find the answers to your questions in the pieces of my code below.

    ...................

    #include <msp430.h>
    #include <msp430fr5972.h>
    #include <float.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <stdint.h>
    
    ...
    // initial after 1-st prog value
    #pragma PERSISTENT(eSW_kn1)
    volatile unsigned char  eSW_kn1=0;

    #pragma PERSISTENT(eSW_kn2)
    volatile unsigned char  eSW_kn2=0;
    ... volatile unsigned char SW_kn1=0, SW_kn2=0, z=0;
    volatile unsigned char Pin9bit4=0;

    volatile unsigned char Zar_regim=0;
    volatile unsigned char SW_Regim=2;

    volatile unsigned char Ibut=0;
    ... if( (P9IN & BIT4)==BIT4) { Pin9bit4 = 1; } else { Pin9bit4 = 0; } ...
    ... SW_kn2=eSW_kn2; if( ++SW_kn2 > 20 ) SW_kn2=0; switch ( __even_in_range( SW_kn2 , 20 ) ){ case 0 : Zar_regim=20; SW_Regim=2; break; case 1 : Zar_regim=3; SW_Regim=3; break; case 2 : Zar_regim=21; SW_Regim=3; break; case 3 : if( Pin9bit4==1 ) {Zar_regim=22; SW_Regim=2;} else { SW_kn2=11; Zar_regim=52; SW_Regim=5;} break; case 4 : if( Pin9bit4==1 ) {Zar_regim=23; SW_Regim=2;} break; case 5 : if( Pin9bit4==1 ) {Zar_regim=24; SW_Regim=2;} break; case 6 : if( Pin9bit4==1 ) {Zar_regim=4; SW_Regim=4;} break; case 7 : if( Pin9bit4==1 ) {Zar_regim=41; SW_Regim=4;} break; case 8 : if( Pin9bit4==1 ) {if(z==6 || z==7) { Zar_regim=44; SW_Regim=4;} else { Zar_regim=42; SW_Regim=4;}} break; case 9 : if( Pin9bit4==1 ) {if(z==6 || z==7) { Zar_regim=44; SW_Regim=4;} else { Zar_regim=42; SW_Regim=4;}} break; case 10 : if( Pin9bit4==1 ) {Zar_regim=44; SW_Regim=4;} break; case 11 : if(z==6 || z==7) {Zar_regim=54; SW_Regim=5;} else {Zar_regim=52; SW_Regim=5;} break; case 12 : if(z==6 || z==7) {Zar_regim=54; SW_Regim=5;} else {Zar_regim=53; SW_Regim=5;} break; case 13 : Zar_regim=54; SW_Regim=5; break; case 14 : if( Pin9bit4==1 ) {Zar_regim=6; SW_Regim=6;} else {SW_kn2=16; Zar_regim=20; SW_Regim=2;} break; case 15 : if( Pin9bit4==1 ) {Zar_regim=7; SW_Regim=7;} break; case 16 : Zar_regim=20; SW_Regim=2; break; case 17 : Zar_regim=20; SW_Regim=2; break; case 18 : Zar_regim=20; SW_Regim=2; break; case 19 : Zar_regim=8; SW_Regim=2; break; case 20 : Zar_regim=9; SW_Regim=2; break; default : __never_executed(); } eSW_kn2=SW_kn2; ...

    ...................

    in my program, before this code (above), I'm using a piece of code that 100% works like written:

    ...
         SW_kn1=eSW_kn1;
            if( ++SW_kn1 > 14 ) SW_kn1=0;
            switch ( __even_in_range( SW_kn1 , 14 ) ){
              case 0 : Ibut=0; break;
              case 1 : Ibut=1; break;
              case 2 : Ibut=2; break;
              case 3 : Ibut=3; break;
              case 4 : Ibut=4; break;
              case 5 : Ibut=5; break;
              case 6 : Ibut=6; break;
              case 7 : Ibut=7; break;
              case 8 : Ibut=8; break;
              case 9 : Ibut=9; break;
              case 10 : Ibut=10; break;
              case 11 : Ibut=11; break;
              case 12 : Ibut=12; break;
              case 13 : Ibut=13; break;
              case 14 : Ibut=14; break;
             default  : __never_executed();
           }
      eSW_kn1=SW_kn1;
    ...

  • Hello Alexander,
    many thanks for the additional information.
    It seems the code has slightly changed. In the previous one, case 4 and case 5 did not contain a break instruction. This might be one part of the problem you've been experiencing.
    In any case, I'll run the tests on my side and come back to you as soon as possible.

    Best regards
    Peter
  • Tomasz
    Peter

    I think that I began to understand the problem.

    But we must start from afar.

    there are no 12, 18, 20 bit architectures of microprocessors.
    It happens only: 8. 16. 32. 64. 128 bits

    I found the time when computers were the size of the floor of the building :)
    And I wrote programs for them. Then I had 4 kilobytes of memory ...

    Such here, when there were computers (chip-processors) which had only 8 bits of capacity, memory was not enough :)
    We invented a 16-bit memory address register, this is so that in the program it would be possible to operate with a "single piece" of memory with a size of 64,000 bytes.

    But that was not enough ...
    And then, 30 years ago (approximately), a brilliant solution was invented: within the memory field 64000 bytes, the "window" was selected. This window could be 8-16-32 kilobytes in size. To manage the "window" came up with a control register, which simply "inserted" into the "window" of memory, a piece of additional memory.

    Thus it became possible for processors 8 and 16 bit architecture to be able to work with 128 kilobytes and more memory.

    But there was a problem ... a big problem.

    Previously, the program was written by People who understood "how it works". Now the program is written by the compiler-machine, which (as we very much hope) should know all these features.
    The problem is how to use (and for what) these "windows".

    The compiler machine should understand that you can not access data or transfer control to pieces of programs that are "in a window that is not currently displayed" (for example, we have 256 kilobytes of memory).
    I wrote programs in assembler for such configurations. This was a difficult task, it was necessary to provide for a lot of small things. This program was difficult to debug, especially if it had several parallel processes.

    That is: before you transfer control "somewhere in the window", the compiler machine must first "insert the glass (code) in the window." If this does not happen in time, we will get a big problem and unpredictable behavior of the microcontroller.

    Let's return to my case.

    My program now takes (after optimization) 41535 bytes of code. It is very close to 48000 bytes of "border to window" memory which is "low" (0 --- 48000). The second "piece" of memory in the MSP430 is 16,000 bytes and is located in the "window" which, in new models of microcontrollers, is used as a "memory window".

    I think that my problem is this.

    The compiler machine is configured to work ONLY with the configuration:
    -vmspx
    --code_model=large
    --data_model=restricted
    --near_data=globals

    configuration:
    -vmspx
    --code_model=small
    --data_model=small

    and

    -vmsp
    --code_model=small
    --data_model=small

    causes errors, because "libraries" do not support these modes.

    It's very sad ...

    As proof, I will give all three memory configurations (pictures) that I get with three memory allocation options.
    The problem with which I began with the MPU is (my opinion) a direct dependence on the "window(memory) support structure".
    It is impossible to "protect" the area located simultaneously in the "window" and in the "bottom code".

    What should I do ?
    I have to think and rewrite my program so that the "windows" do not interfere with the compiler (and me) to build such code that would not be placed in different pieces of memory unpredictable (known only to the compiler-machine) way.

    It is sad.
    I thought I could solve the problem in an easier way.

    And I was wrong choosing a 16 bit architecture for my tasks.
    I needed to select 32 bits.

    Now I would like to ask for advice on how to make my data persistent (text messages for LSD, no executable code!) Render in the "window"(FRAM2), this will relieve the space for the executable code in the "lower part"(FRAM) and allow me to remove the problem.

  • Alexander,

    lets fix it quickly.

    YOU: there are no 12, 18, 20 bit architectures of microprocessors.
    It happens only: 8. 16. 32. 64. 128 bits.

    I fully agree.
    When someone says 16 bits architecture that means the CPU has 16 bits long word.
    However at 60s/70s Control Data Corporation supercomputers had 9 bits word.
    What about Intel 4004?
    A Ti's competitor has sold 15+ billions of MCUs with 12, 14, 16 and 24 bits long words.

    A brilliant "window" solution was present in 60s in IBM 360 and was fundamental for its virtual memory and later for its virtual machines.
    Yes, Virtual Machine ware implemented for first time when I was implemented.
    A brilliant "window" solution was present mid 70s in 6502 CPUs which were used in Atari, Commodore and Apple II.
    It was called paging and is still used under this name in Microchip PIC MCUs.


    In my first reply to you I wrote:
    5972 is based on 20 bits bus architecture so, in most cases, you should keep mspx on.
    Sometime later I have missed a word "bus" before an architecture.
    Correct statement should be:
    5972 is based on 20 bits addressing bus architecture so, in most cases, you should keep mspx on.

    Also, in my first reply to you I recommended to switch to TI v16.9.8LTS.
    Why do not you try it?

    To install it you just need to go to Help -> Install Code Generation Compiler Tools... and select needed version and helps for it,
    than restart CCS and within a Project Properties -> CCS General you would be able to switch compiler version.
  • new miracle :)


    works before case 11 then does not work (case 12....20 dont work) at all
    and with a probability of 50% leads to the hang of my device.

    ... I probably need the help of a psychiatrist ... :)

  • Dear Alexander,

    never give up.

    I hope, later today I will find time to put your code on my LP.
    Right now I see that at the begin of the ISR:
    SW_kn2=eSW_kn2;
    Where eSW_kn2 is updated?
    Maybe eSW_kn2 never reaches < 21 value.
    Could be a s/w issue, not tools.
  • Regarding the first switch instruction:
    having SW_kn2 == 20 or bigger, you do a pre-increment,
    then the if ( ... > 20 ) sets SW_kn2 to 0.
    This code never enters cases 1 to 10.
  • I needed just a moment to read your ISR() code.
    However I needed a piece of time to read it.

    If you improve your coding style / layout to form below,
    you would probably avoid an error related to cases 1-10, even being very tired.

         SW_kn2=eSW_kn2;
    
         if( ++SW_kn2 > 20 )
             SW_kn2=0;
         switch (  SW_kn2 ) {
            case 0 : Zar_regim=20; SW_Regim=2; break;
            case 1 : Zar_regim=3;  SW_Regim=3; break;
            case 2 : Zar_regim=21; SW_Regim=3; break;
            case 3 : Zar_regim=22; SW_Regim=2; break;
            case 4 : Zar_regim=23; SW_Regim=2; break;
            case 5 : Zar_regim=24; SW_Regim=2; break;
            case 6 : Zar_regim=4;  SW_Regim=4; break;
            case 7 : Zar_regim=41; SW_Regim=4; break;
            case 8 : Zar_regim=42; SW_Regim=4; break;
            case 9 : Zar_regim=43; SW_Regim=4; break;
            case 10 : Zar_regim=44; SW_Regim=4; break;
            default : __never_executed();
         }
    
         if( SW_kn2 >= 11 ) { 
             SW_kn3=SW_kn2;
             switch (  SW_kn3 ){
                 case 11 : Zar_regim=52; SW_Regim=5; break;
                 case 12 : Zar_regim=53; SW_Regim=5; break;
                 case 13 : Zar_regim=54; SW_Regim=5; break;
                 case 14 : Zar_regim=6; SW_Regim=6; break; 
                 case 15 : Zar_regim=7; SW_Regim=7; break; 
                 case 16 : Zar_regim=20; SW_Regim=2; break;
                 case 17 : Zar_regim=20; SW_Regim=2; break;
                 case 18 : Zar_regim=20; SW_Regim=2; break;
                 case 19 : Zar_regim=8; SW_Regim=2; break; 
                 case 20 : Zar_regim=9; SW_Regim=2; break; 
                 default : __never_executed();
            }
         }
    

  • to Tomasz

    > Regarding the first switch instruction:
    > having SW_kn2 == 20 or bigger, you do a pre-increment,
    > then the if ( ... > 20 ) sets SW_kn2 to 0.
    > This code never enters cases 1 to 10.

    This code has been working for three years already :)
    on the atmel.
    and on msp430 also works, but only the first 0-1-2
  • To Alexander and Peter,

    Your :) statement that this code has been working for three years already
    does not mean that this code has been properly working.
    Atmel does not exist.
    Please do not melt to much.

    Peter,
    do you agree with me that the above code cannot enter cases 1 and 2?
  • Hello Alexander,
    do you have a flow chart for the code portion, which you're struggling with, that describes the functionality, which you intend to implement?
    This would help, as there have been quite some changes on the code from your side, thus it is not perfectly clear to me, what the loop should do. Please give us a description.

    Best regards
    Peter
  • Tomasz

    > Peter,
    > do you agree with me that the above code cannot enter cases 1 and 2?

    this code is used for cyclic (0-1-2 -....- 20) enumeration of options for settings (modes) from the button.
    Yes, it really does not work with 0 and with 1-2-3 -...- 20.

  • Peter

    I do not draw diagrams :)
    I draw diagrams in my brain and then convert them to code.

    This code is used for cyclic (0-1-2 -...- 20) enumeration of modes options in my device.
    This code inside the Timer1 A0 is called once every 0.5 seconds.
    Its task is just to work out what is written. (see the code above)
    Nothing else.

    in fact, it turns out that I have the main loop (main.c,  while(1) ) in which the algorithm is being processed, and there are interrupts (Timer1 ...) which simply modify variables (as volatiles).

    The basic algorithm always rotates and "looks" into variables, and uses them in calculations and for making decisions about changing modes. This can be called parallel computation.
    I have been using this mechanism for working with buttons for 8 years already. Everything worked before I moved to MSR430 :(

    In another place in the program (the main body), changes occur that are caused by variables that change at the click of a button.

    When the button is pressed, it is not polled, and once every 0.5 seconds Timer1 is interrupted, it looks 0-1 at the corresponding pin of the microcontroller.

    (P7IN & BIT1)!=BIT1 -- If the button is pressed (at the microcontroller input = 0)

    (P7IN & BIT1)==BIT1 --- in case the button is not pressed (at the input of the microcontroller = 1), the pin is pulled up by an external resistor to + 3.3V of the power supply.

    this is checked every 0.5 seconds within Timer1 code.

    If the button is not pressed, nothing happens, this code is not executed.
    Nowhere in other parts of the program does anyone change the value of SW_kn2.
    Only in this place Timer1, the 0-1 output of the button is read out and the decision is made to change the parameters of the variables (see the code)

    There is no stack overflow (the stack size does not affect the work at all).

    I moved this piece of code to other places, but nothing changes, this place seems to be bewitched :(

    The device has two more buttons - on them the changes occur with a 100% guarantee, the same mechanism.

    On the other buttons there are 14 positions in the switch and 7 positions in the switch - everything works exactly as it is written 100%.

  • Alexander,

    <<< Yes, it really does not work with 0 and with 1-2-3 -...- 20.
    Sould be: Yes, it really works with 0 and not with 1-20.

    What's next?
  • Tomasz

    it really WORK with 1-2-3...-20-0-1-2-3-...

    the first entrance to the case SW_kn2 = 1.
    second entrance to the case SW_kn2 = 2.
    ...
    twentieth = 20
    twenty first = 0

    ...

  • Sorry!

    You are right.
    Probably too many phone calls when I replying to you.
  • I'm tired of all these digging
    ...
    I close the topic, because I did not find the answers to my questions.
    I'll rest for a couple of days and start completely rewriting a piece of my program responsible for choosing the modes of operation of my device.

    To all who have spent their time reading and helping me - I express my great gratitude!

    I still consider the MSP430 to be the best device (family) for my choice.

**Attention** This is a public forum