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.

CC1310: Go to address not working

Part Number: CC1310
Other Parts Discussed in Thread: SYSBIOS, CC2650, CC1350

Hi,

I loaded two applications in the CC1310 flash.

The first one is located at address 0x0000 and the second at address 0xA000.

In the first application, I want to jump to the second application if the button is pressed.

I made the following program and it is working! I am able to jump to the second application when using that program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
 *  ======== pinInterrupt.c ========
 */
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Assert.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
/* TI-RTOS Header files */
#include <ti/drivers/PIN.h>
#include <ti/drivers/pin/PINCC26XX.h>
#include <driverlib/flash.h>
#include <driverlib/vims.h>
#include <ti/drivers/UART.h>
/* Example/Board Header files */
#include "Board.h"
#include <string.h>
#define TASKSTACKSIZE     768
Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
static Clock_Struct clockStruct;
static UART_Handle uart;
/* Pin driver handles */
static PIN_Handle buttonPinHandle;
static PIN_Handle ledPinHandle;
/* Global memory storage for a PIN_Config table */
static PIN_State buttonPinState;
static PIN_State ledPinState;
/*
 * Initial LED pin configuration table
 *   - LEDs Board_LED0 is on.
 *   - LEDs Board_LED1 is off.
 */
PIN_Config ledPinTable[] = {
    Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
};
/*
 * Application button pin configuration table:
 *   - Buttons interrupts are configured to trigger on falling edge.
 */
PIN_Config buttonPinTable[] = {
    Board_BUTTON0  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    Board_BUTTON1  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    PIN_TERMINATE
};
/*
 *  ======== buttonCallbackFxn ========
 *  Pin interrupt Callback function board buttons configured in the pinTable.
 *  If Board_LED3 and Board_LED4 are defined, then we'll add them to the PIN
 *  callback function.
 */
void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
    uint32_t currVal = 0;
    /* Debounce logic, only toggle if the button is still pushed (low) */
    CPUdelay(8000*50);
    if (!PIN_getInputValue(pinId)) {
        /* Toggle LED based on the button pressed */
        switch (pinId) {
            case Board_BUTTON0:
                currVal =  PIN_getOutputValue(Board_LED0);
                PIN_setOutputValue(ledPinHandle, Board_LED0, !currVal);
                break;
            case Board_BUTTON1:
                // Load address of reset function from the fixed location of the image's
                // reset vector and jump.
                asm(" MOV R0, #0x0A000 ");
                asm(" LDR R1, [R0, #0x4] ");
                // Reset the stack pointer,
                asm(" LDR SP, [R0, #0x0] ");
                // And jump.
                asm(" BX R1 ");
                break;
            default:
                /* Do nothing */
                break;
        }
    }
}
uint32_t milli_to_ticks(uint32_t milli)
{
    return((milli * 1000) / Clock_tickPeriod);
}
uint32_t sec_to_ticks(uint32_t sec)
{
    return(milli_to_ticks(sec * 1000));
}
void blink_led(UArg arg0)
{
    PIN_setOutputValue(ledPinHandle,Board_LED1,!PIN_getOutputValue(Board_LED1));
}
void echoFxn(UArg arg0, UArg arg1)
{
    uint8_t ch;
    while (1)
    {
        Task_sleep(1000);
//        if(!UART_read(uart, &ch, 1))
//        {
//            // Do something
//        }
//        else
//        {
//            // Do something
//        }
    }
}
/*
 *  ======== main ========
 */
int main(void)
{
    /* Call board init functions */
    Board_initGeneral();
    Board_initUART();
    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, ledPinTable);
    if(!ledPinHandle) {
        System_abort("Error initializing board LED pins\n");
    }
    buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
    if(!buttonPinHandle) {
        System_abort("Error initializing button pins\n");
    }
    /* Setup callback for button pins */
    if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) {
        System_abort("Error registering button callback function");
    }
    Clock_Params clockParams;
    Clock_Params_init(&clockParams);
    clockParams.period = milli_to_ticks(250);
    clockParams.startFlag = TRUE;
    Clock_construct(&clockStruct, blink_led, clockParams.period, &clockParams);
    UART_Params uartParams;
    UART_Params_init(&uartParams);
    uartParams.baudRate = 9600;
    uartParams.dataLength = UART_LEN_8;
    uartParams.stopBits = UART_STOP_ONE;
    uartParams.parityType = UART_PAR_NONE;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.readMode = UART_MODE_BLOCKING;
    uartParams.writeMode = UART_MODE_BLOCKING;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readTimeout = UART_WAIT_FOREVER;
    uartParams.writeTimeout = UART_WAIT_FOREVER;
    uart = UART_open(Board_UART0, &uartParams);
    /* Construct BIOS objects */
    Task_Params taskParams;
    Task_Params_init(&taskParams);
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)echoFxn, &taskParams, NULL);
    /* Start kernel. */
    BIOS_start();
    return (0);
}

The problem appear when I uncomment the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void echoFxn(UArg arg0, UArg arg1)
{
    uint8_t ch;
    while (1)
    {
        Task_sleep(1000);
// THE JUMP STOP WORKING WHEN THIS PART IS UNCOMMENTED
//        if(!UART_read(uart, &ch, 1))
//        {
//            // Do something
//        }
//        else
//        {
//            // Do something
//        }
    }
}

That is the only change from the working program to the one that doesn't work.

I don't know if it is relevant, but in both applications I commented:

1
2
3
4
5
6
7
8
9
10
11
12
13
/* ================ ROM configuration ================ */
/*
 * To use BIOS in flash, comment out the code block below.
 */
/*
var ROM = xdc.useModule('ti.sysbios.rom.ROM');
if (Program.cpu.deviceName.match(/CC26/)) {
    ROM.romName = ROM.CC2650;
}
else if (Program.cpu.deviceName.match(/CC13/)) {
    ROM.romName = ROM.CC1350;
}
*/

Can someone help me to understand why the jump stop working when I used the uart driver?