1;//###########################################################################
2;//
3;// FILE:  F2837xD_CodeStartBranch.asm
4;//
5;// TITLE: Branch for redirecting code execution after boot.
6;//
7;// For these examples, code_start is the first code that is executed after
8;// exiting the boot ROM code.
9;//
10;// The codestart section in the linker cmd file is used to physically place
11;// this code at the correct memory location.  This section should be placed
12;// at the location the BOOT ROM will re-direct the code to.  For example,
13;// for boot to FLASH this code will be located at 0x3f7ff6.
14;//
15;// In addition, the example F2837xD projects are setup such that the codegen
16;// entry point is also set to the code_start label.  This is done by linker
17;// option -e in the project build options.  When the debugger loads the code,
18;// it will automatically set the PC to the "entry point" address indicated by
19;// the -e linker option.  In this case the debugger is simply assigning the PC,
20;// it is not the same as a full reset of the device.
21;//
22;// The compiler may warn that the entry point for the project is other then
23;//  _c_init00.  _c_init00 is the C environment setup and is run before
24;// main() is entered. The code_start code will re-direct the execution
25;// to _c_init00 and thus there is no worry and this warning can be ignored.
26;//
27;//###########################################################################
28;// $TI Release: F2837xD Support Library v3.05.00.00 $
29;// $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
30;// $Copyright:
31;// Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
32;//
33;// Redistribution and use in source and binary forms, with or without
34;// modification, are permitted provided that the following conditions
35;// are met:
36;//
37;//   Redistributions of source code must retain the above copyright
38;//   notice, this list of conditions and the following disclaimer.
39;//
40;//   Redistributions in binary form must reproduce the above copyright
41;//   notice, this list of conditions and the following disclaimer in the
42;//   documentation and/or other materials provided with the
43;//   distribution.
44;//
45;//   Neither the name of Texas Instruments Incorporated nor the names of
46;//   its contributors may be used to endorse or promote products derived
47;//   from this software without specific prior written permission.
48;//
49;// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
50;// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
51;// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
52;// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
53;// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
54;// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
55;// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56;// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
57;// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
58;// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
59;// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60;// $
61;//###########################################################################
62
63***********************************************************************
64
65WD_DISABLE  .set  0    ;set to 1 to disable WD, else set to 0
66
67    .ref _c_int00
68    .global code_start
69
70***********************************************************************
71* Function: codestart section
72*
73* Description: Branch to code starting point
74***********************************************************************
75
76    .sect "codestart"
77
78code_start:
79    .if WD_DISABLE == 1
80        LB wd_disable       ;Branch to watchdog disable code
81    .else
82        LB _c_int00         ;Branch to start of boot._asm in RTS library
83    .endif
84
85;end codestart section
86
87***********************************************************************
88* Function: wd_disable
89*
90* Description: Disables the watchdog timer
91***********************************************************************
92    .if WD_DISABLE == 1
93
94    .text
95wd_disable:
96    SETC OBJMODE        ;Set OBJMODE for 28x object code
97    EALLOW              ;Enable EALLOW protected register access
98    MOVZ DP, #7029h>>6  ;Set data page for WDCR register
99    MOV @7029h, #0068h  ;Set WDDIS bit in WDCR to disable WD
100    EDIS                ;Disable EALLOW protected register access
101    LB _c_int00         ;Branch to start of boot._asm in RTS library
102
103    .endif
104
105;end wd_disable
106
107    .end
108
109;//
110;// End of file.
111;//
112