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.

Software breakpoints cannot be set on the given opcode

Other Parts Discussed in Thread: MSP430FR5969

Working on my ADC routines, I ran into this:

MSP430:  There were 6398 (code) and 68 (data) bytes written to FLASH/FRAM. The expected RAM usage is 1962 (uninitialized data + stack) bytes.
MSP430: Trouble Setting Breakpoint with the Action "Finish Auto Run" at 0x5646: Software breakpoints cannot be set on the given opcode.

So what gives? That's apparently automatically set breakpoint and now I cannot do source stepping among other things. I've got MSP430fr5969 and according to my memory map I've got plenty of ram to play with. 

Offending code memory looks like this:

        main():
005646:   403C 0150           MOV.W   #0x0150,R12
00564a:   12B0 5E00           CALL    #WDT_A_hold

  • For what it's worth, I verified this happens with both launchpad and on my actual PCB.
  • Hello Olli,

    It sounds like a HW breakpoint is needed for the auto one ehre,a nd you maybe using them all elsewhere. Can you try the following?
    In CCs, right click project and head to Properties.
    Click on Debug Menu
    Under MSP43x Options, make sure Hardware is set for default breakpoint type
    Under Auto Run and Launch Options: You can try disabling Auto Run, Uncheck Restore breakpoints form previous session.

    Additionally, you can check the Breakpoint window (View -> Breakpoints) to uncheck specific breakpoints.
  • 
    

    That makes the initial error message go away but I still cannot source step.

    MSP430: Can't Single Step Target Program: Could not single step device

    I think I figured out what caused the problem but not exactly why it happened. 

    I have a source file that defines a lookup table which I left as a .c file although it could just as well be a header file. If I convert that to header and remove the extern references from the main program this problem goes away. This sound like a known issue? 

    as3824.h

    /* Test application for ADC temperature / light value recording
     * (c) Sharp Devices Europe 2016, Olli M�nnist�
     * v0.2 adjusted to read internal temperature sensor values
     * v0.21 convert values do degrees with a lookup table
     * Uses MCLK for ADC clock with 8 divisor => 1MHz sample clock
     * ADC12BMEM0 = internal temperature TCMAP
     * ADC12BMEM1 = TEMP1 LED connector board near A0
     * ADC12BMEM2 = TEMP2 LED connector board remote A2
     * ADC12BMEM3 = TEMP3 LED driver remote A13
     * ADC12BMEM4 = TEMP4 LED driver next to SMPS5 A15
     * ADC12BMEM5 = TEMP5 LED driver next to SMPS3 A4
     * ADC12BMEM6 = LIGHT1 LED connector board on-board A1
     * ADC12BMEM7 = LIGHT2 LED connector board remote A12
     * ADC12BMEM8 = LIGHT3 LED driver remote A14
     * ADC12BMEM9 = VLED1 SMPS1 A5
     * ADC12BMEM10 = VLED2 SMPS2 A8
     * ADC12BMEM11 = VLED3 SMPS3 A9
     * ADC12BMEM12 = VLED4 SMPS4 A10
     * ADC12BMEM13 = VLED5 SMPS5 A11
     * ADC12BMEM14 = VLED4 SMPS6 A6
     * TEMP1 P1.0
     * TEMP2 P1.2
     * TEMP3 P3.1
     * TEMP4 P3.3
     * TEMP5 P1.4
     * LIGHT1 P1.1
     * LIGHT2 P3.0
     * LIGHT3 P3.2
     * VLED1 P1.5
     * VLED2 P4.0
     * VLED3 P4.1
     * VLED4 P4.2
     * VLED5 P4.3
     * VLED6 P2.3
     */
    
    /*Original Texas copyright although there's not that much left of the original example..*/
    
    /* --COPYRIGHT--,BSD
     * Copyright (c) 2016, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    
    #include "driverlib.h"
    #include "as3824.h"
    #include "stdio.h"
    #include "string.h"
    #include "stdlib.h"
    
    /* #include "ADC_Lookup.h"
    */
    #define USHORT uint16_t
    #define SHORT int16_t
    #define UCHAR uint8_t
    #define CHAR int8_t
    #define ULONG uint32_t
    #define LONG int32_t
    #define VALY 8
    
    void Init_Adc();
    void Init_Adc_Ports();
    void Init_Adc_Mem(UCHAR memory, UCHAR input, USHORT sequence);
    void Convert_Sensor(char values[][VALY], UCHAR valx, UCHAR valy);
    
    extern USHORT * ADCTEMP;
    extern USHORT ADCLOOKUP;
    
    
    
    USHORT temp;
    volatile USHORT sensors[16]={0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0
    };
    
    void main(void)
    {
        // Stop WDT
        WDT_A_hold(WDT_A_BASE);
    /*
     * Setup ADC ports
     */
        Init_Adc_Ports();
    
        /*
         * Disable the GPIO power-on default high-impedance mode to activate
         * previously configured port settings
         */
        PMM_unlockLPM5();
    /*
     * Setup ref voltage to 2.5V
     */
        Ref_A_setReferenceVoltage(REF_A_BASE, REF_A_VREF2_5V);
    
    /*
     * Setup ADC
     */
        Init_Adc();
    
    
        while(1)
        {
        	static char values[15][VALY];
        	static UCHAR valx, valy;
        	valx=sizeof(values)/sizeof(values[0]);
        	valy=sizeof(values[0])/sizeof(values[0][0]);
            __delay_cycles(5000);
    
            //Enable/Start sampling and conversion
            /*
             * Base address of ADC12B Module
             * Start the conversion into memory buffer 0
             * Use the sequence of channels, single-conversion mode
             */
            ADC12_B_startConversion(ADC12_B_BASE,
                                    ADC12_B_MEMORY_0,
    								ADC12_B_SEQOFCHANNELS);
    
            __bis_SR_register(LPM0_bits + GIE);     // LPM0, ADC12_B_ISR will force exit
            __no_operation();                       // For debugger
            Convert_Sensor(values, valx, valy);
    /*        printf("TEMPI %x, TEMP1 %x, TEMP2 %x, TEMP3 %x, TEMP4 %x, TEMP5 %x, LIGHT1 %x, LIGHT2 %x, LIGHT3 %x\n"
            		 "VLED1 %x, VLED2 %x, VLED3 %x, VLED4 %x, VLED5 %x, VLED6 %x \n",
            		sensors[0],sensors[1],sensors[2],sensors[3],sensors[4],sensors[5],sensors[6],sensors[7],
    				sensors[8],sensors[9],sensors[10],sensors[11],sensors[12],sensors[13],sensors[14]);
    				*/
        }
    }
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=ADC12_VECTOR
    __interrupt
    #elif defined(__GNUC__)
    __attribute__((interrupt(ADC12_VECTOR)))
    #endif
    void ADC12_ISR(void)
    {
        switch(__even_in_range(ADC12IV,40))
        {
        case  0: break;                         // Vector  0:  No interrupt
        case  2: break;                         // Vector  2:  ADC12BMEMx Overflow
        case  4: break;                         // Vector  4:  Conversion time overflow
        case  6: break;                         // Vector  6:  ADC12BHI
        case  8: break;                         // Vector  8:  ADC12BLO
        case 10: break;                         // Vector 10:  ADC12BIN
        case 12:                                // Vector 12:  ADC12BMEM0 Interrupt
        	sensors[0] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_0);
            break;                              // Clear CPUOFF bit from 0(SR)
        case 14:	                          // Vector 14:  ADC12BMEM1
        	sensors[1] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_1);
        	break;
        case 16:                          // Vector 16:  ADC12BMEM2
        	sensors[2] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_2);
        	break;
        case 18:                          // Vector 18:  ADC12BMEM3
        	sensors[3] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_3);
        	break;
        case 20:                          // Vector 20:  ADC12BMEM4
        	sensors[4] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_4);
    		break;
        case 22:                          // Vector 22:  ADC12BMEM5
        	sensors[5] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_5);
        	break;
        case 24:                          // Vector 24:  ADC12BMEM6
        	sensors[6] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_6);
        	break;
        case 26:                          // Vector 26:  ADC12BMEM7
        	sensors[7] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_7);
        	break;
        case 28:                          // Vector 28:  ADC12BMEM8
        	sensors[8] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_8);
        	break;
        case 30:                          // Vector 30:  ADC12BMEM9
        	sensors[9] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_9);
        	break;
        case 32:                          // Vector 32:  ADC12BMEM10
        	sensors[10] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_10);
        	break;
        case 34:                          // Vector 34:  ADC12BMEM11
        	sensors[11] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_11);
        	break;
        case 36:                          // Vector 36:  ADC12BMEM12
        	sensors[12] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_12);
        	break;
        case 38:                          // Vector 38:  ADC12BMEM13
        	sensors[13] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_13);
        	break;
        case 40:                   				// Vector 40:  ADC12BMEM14
        	sensors[14] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_14);
        	__bic_SR_register_on_exit(LPM0_bits);   // last in sequence, Exit active CPU
        	break;
        default: _never_executed();
        }
    }
    
    void Init_Adc(void){
        //Initialize the ADC12B Module
        /*
         * Base address of ADC12B Module
         * Use internal ADC12B bit as sample/hold signal to start conversion
         * USE MODOSC 5MHZ Digital Oscillator as clock source
         * Use default clock divider 5 => 1MHz ADC clock
         * Not use internal channel
         */
        ADC12_B_initParam initParam = {0};
        initParam.sampleHoldSignalSourceSelect = ADC12_B_SAMPLEHOLDSOURCE_SC;
        initParam.clockSourceSelect = ADC12_B_CLOCKSOURCE_ADC12OSC;
        initParam.clockSourceDivider = ADC12_B_CLOCKDIVIDER_5;
        initParam.clockSourcePredivider = ADC12_B_CLOCKPREDIVIDER__1;
        initParam.internalChannelMap = ADC12_B_TEMPSENSEMAP;
        ADC12_B_init(ADC12_B_BASE, &initParam);
    
        //Enable the ADC12B module
        ADC12_B_enable(ADC12_B_BASE);
    
        /*
         * Base address of ADC12B Module
         * For memory buffers 0-7 sample/hold for 64 clock cycles
         * For memory buffers 8-15 sample/hold for 4 clock cycles (default)
         * Disable Multiple Sampling
         * We need 30us conversion time for temperature sensor so 32 cycles
         */
        ADC12_B_setupSamplingTimer(ADC12_B_BASE,
                                   ADC12_B_CYCLEHOLD_64_CYCLES,
                                   ADC12_B_CYCLEHOLD_4_CYCLES,
                                   ADC12_B_MULTIPLESAMPLESENABLE);
    
        Init_Adc_Mem(ADC12_B_MEMORY_0, ADC12_B_INPUT_TCMAP, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_1, ADC12_B_INPUT_A0, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_2, ADC12_B_INPUT_A2, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_3, ADC12_B_INPUT_A13, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_4, ADC12_B_INPUT_A15, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_5, ADC12_B_INPUT_A4, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_6, ADC12_B_INPUT_A1, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_7, ADC12_B_INPUT_A12, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_8, ADC12_B_INPUT_A14, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_9, ADC12_B_INPUT_A5, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_10, ADC12_B_INPUT_A8, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_11, ADC12_B_INPUT_A9, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_12, ADC12_B_INPUT_A10, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_13, ADC12_B_INPUT_A11, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_14, ADC12_B_INPUT_A6, ADC12_B_ENDOFSEQUENCE);
    
        ADC12_B_clearInterrupt(ADC12_B_BASE,
                               0,
                               0xFFFF
                               );
        ADC12_B_clearInterrupt(ADC12_B_BASE,
                               1,
                               0xFFFF^ADC12_B_IFG15
                               );
        //Enable memory buffer 0-14 interrupts
        ADC12_B_enableInterrupt(ADC12_B_BASE,
                                0xFFFF^ADC12_B_IE15,
                                0,
                                0);
    };
    
    /*
     * Setup pins related to ADC
     */
    void Init_Adc_Ports(){
        //Set ADC ports as ternary function inputs
        /*
    
         * Select Port 1
        * Set Pins 0,1,2,4 and 5 to input Ternary Module Function, (A0-5, C1, VREF+, VeREF+).
         */
        GPIO_setAsPeripheralModuleFunctionInputPin(
            GPIO_PORT_P1,
            GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN4+GPIO_PIN5,
            GPIO_TERNARY_MODULE_FUNCTION
            );
        /*
        * Select Port 2
        * Set Pin 3 input Ternary Module Function, (A6, C1, VREF+, VeREF+).
        */
       GPIO_setAsPeripheralModuleFunctionInputPin(
           GPIO_PORT_P2,
           GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3,
           GPIO_TERNARY_MODULE_FUNCTION
           );
        /*
        * Select Port 3
        * Set Pins 0,1,2,3 input Ternary Module Function, (A12-15)
        */
       GPIO_setAsPeripheralModuleFunctionInputPin(
           GPIO_PORT_P3,
           GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3,
           GPIO_TERNARY_MODULE_FUNCTION
           );
    
       /*
       * Select Port 4
       * Set Pins 0,1,2,3 input Ternary Module Function, (A8-11).
       */
      GPIO_setAsPeripheralModuleFunctionInputPin(
          GPIO_PORT_P4,
          GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3,
          GPIO_TERNARY_MODULE_FUNCTION
          );
    };
    
    void Init_Adc_Mem(UCHAR memory, UCHAR input, USHORT sequence){
        //Configure Memory Buffer
        /*
         * Base address of the ADC12B Module
         * Configure memory buffer x
         * Map input z to memory buffer x
         * Vref+ = AVcc
         * Vref- = AVss
         * Memory buffer x is (not) the end of a sequence
         */
        ADC12_B_configureMemoryParam configureMemoryParam = {0};
        configureMemoryParam.memoryBufferControlIndex = memory;
        configureMemoryParam.inputSourceSelect = input;
        configureMemoryParam.refVoltageSourceSelect =
        	ADC12_B_VREFPOS_INTBUF_VREFNEG_VSS;
        configureMemoryParam.endOfSequence = sequence;
        configureMemoryParam.windowComparatorSelect =
            ADC12_B_WINDOW_COMPARATOR_DISABLE;
        configureMemoryParam.differentialModeSelect =
            ADC12_B_DIFFERENTIAL_MODE_DISABLE;
        ADC12_B_configureMemory(ADC12_B_BASE, &configureMemoryParam);
    }
    
    void Convert_Sensor(char values[][VALY], UCHAR valx, UCHAR valy){
    	SHORT i=0;
    	if (sensors[0]<0x3D7) {
    		strcpy((char *) values[0],"LOW\0");
    	}
    	else{
    		ltoa(((((ULONG)sensors[0]-0x3D7)*1000)>>12)-40, values[0]);
    		printf("temperature internal %s\n", values[0]);
    	};
    	/*
    	 * This means we're out of bounds i.e. cooking
    	 */
    	if(ADCTEMP[ADCLOOKUP-1]>sensors[1]){
    		strcpy("HOT\0", values[1]);
    	}
    	else{
    		for(i=0; i<ADCLOOKUP; i=i+16){
    			if(ADCTEMP[i]<sensors[1]){
    				for(;ADCTEMP[i]<sensors[1];i--){
    					if(i<0){
    						break;
    					}
    				}
    				if(i>-1){
    					ltoa((long) i, values[1]);
    					break;
    				}
    				else{
    					strcpy("LOW\0", values[1]);
    					break;
    				}
    			}
    		}
    	}
    	printf("temp1 %s\n", values[1]);
    }
    

    /*
     * ADC_Lookup.c
     *
     *  Created on: 18 Nov 2016
     *      Author: Olli.Mannisto
     *      We define some lookup tables for temperature and light sensors. MSP430 isn't exactly fast
     *      doing divisions and multiplications..
     */
    
    #ifndef ADC_LOOKUP_H
    #define ADC_LOOKUP_H
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #include "driverlib.h"
    #define USHORT uint16_t
    #define UCHAR uint8_t
    #define ULONG uint32_t
    
    
    const USHORT ADCLOOKUP=127; //Temperature lookup table size
    
    const USHORT ADCTEMP[]={0xF72, // 0
    		0xF40, // 1
    		0xF0E, // 2
    		0xEDB, // 3
    		0xEA8, // 4
    		0xE86, // 5
    		0xE52, // 6
    		0xE1D, // 7
    		0xDE8, // 8
    		0xDB3, // 9
    		0xD8E, // 10
    		0xD58, // 11
    		0xD23, // 12
    		0xCEC, // 13
    		0xCB6, // 14
    		0xC8F, // 15
    		0xC59, // 16
    		0xC22, // 17
    		0xBEC, // 18
    		0xBB6, // 19
    		0xB8E, // 20
    		0xB58, // 21
    		0xB22, // 22
    		0xAED, // 23
    		0xAB8, // 24
    		0xA8F, // 25
    		0xA5B, // 26
    		0xA27, // 27
    		0x9F3, // 28
    		0x9C0, // 29
    		0x996, // 30
    		0x964, // 31
    		0x932, // 32
    		0x901, // 33
    		0x8D1, // 34
    		0x8A8, // 35
    		0x879, // 36
    		0x84A, // 37
    		0x81C, // 38
    		0x7EF, // 39
    		0x7C8, // 40
    		0x79C, // 41
    		0x770, // 42
    		0x746, // 43
    		0x71C, // 44
    		0x6F6, // 45
    		0x6CD, // 46
    		0x6A6, // 47
    		0x67F, // 48
    		0x658, // 49
    		0x634, // 50
    		0x60F, // 51
    		0x5EB, // 52
    		0x5C8, // 53
    		0x5A6, // 54
    		0x584, // 55
    		0x562, // 56
    		0x542, // 57
    		0x522, // 58
    		0x503, // 59
    		0x4E4, // 60
    		0x4C6, // 61
    		0x4A9, // 62
    		0x48D, // 63
    		0x471, // 64
    		0x456, // 65
    		0x43C, // 66
    		0x422, // 67
    		0x409, // 68
    		0x3F1, // 69
    		0x3D9, // 70
    		0x3C1, // 71
    		0x3AA, // 72
    		0x394, // 73
    		0x37F, // 74
    		0x368, // 75
    		0x354, // 76
    		0x340, // 77
    		0x32C, // 78
    		0x319, // 79
    		0x305, // 80
    		0x2F3, // 81
    		0x2E1, // 82
    		0x2D0, // 83
    		0x2BF, // 84
    		0x2AD, // 85
    		0x29D, // 86
    		0x28E, // 87
    		0x27E, // 88
    		0x270, // 89
    		0x260, // 90
    		0x252, // 91
    		0x244, // 92
    		0x237, // 93
    		0x22A, // 94
    		0x21C, // 95
    		0x20F, // 96
    		0x204, // 97
    		0x1F8, // 98
    		0x1ED, // 99
    		0x1DF, // 100
    		0x1D5, // 101
    		0x1CA, // 102
    		0x1C0, // 103
    		0x1B6, // 104
    		0x1AB, // 105
    		0x1A1, // 106
    		0x198, // 107
    		0x18F, // 108
    		0x187, // 109
    		0x17C, // 110
    		0x174, // 111
    		0x16C, // 112
    		0x164, // 113
    		0x15D, // 114
    		0x154, // 115
    		0x14D, // 116
    		0x146, // 117
    		0x13F, // 118
    		0x138, // 119
    		0x130, // 120
    		0x129, // 121
    		0x123, // 122
    		0x11D, // 123
    		0x117, // 124
    		0x110, // 125
    		0x10B // 126
    };
    
    #ifdef __cplusplus
    }
    #endif /* extern "C" */
    
    #endif // ADC_LOOKUP_H
    

  • Problem not solved. This keeps coming back when I change things in the code. With the current version if I have the "autorun to main" option checked I get the complaint about the software breakpoint.

    This happens if I have a grand total of one breakpoint set in the code (from previous session). Source stepping works now but hitting pause drops me into random library including empty "no source available for 0x2" tab.

    /* Test application for ADC temperature / light value recording
     * (c) Sharp Devices Europe 2016, Olli M�nnist�
     * v0.2 adjusted to read internal temperature sensor values
     * v0.21 convert internal temperature to degrees
     * v0.3 convert external temperature values to degrees with a lookup table
     * v0.31 convert light sensor to lux
     * Uses MCLK for ADC clock with 8 divisor => 1MHz sample clock
     * ADC12BMEM0 = internal temperature TCMAP
     * ADC12BMEM1 = TEMP1 LED connector board near A0
     * ADC12BMEM2 = TEMP2 LED connector board remote A2
     * ADC12BMEM3 = TEMP3 LED driver remote A13
     * ADC12BMEM4 = TEMP4 LED driver next to SMPS5 A15
     * ADC12BMEM5 = TEMP5 LED driver next to SMPS3 A4
     * ADC12BMEM6 = LIGHT1 LED connector board on-board A1
     * ADC12BMEM7 = LIGHT2 LED connector board remote A12
     * ADC12BMEM8 = LIGHT3 LED driver remote A14
     * ADC12BMEM9 = VLED1 SMPS1 A5
     * ADC12BMEM10 = VLED2 SMPS2 A8
     * ADC12BMEM11 = VLED3 SMPS3 A9
     * ADC12BMEM12 = VLED4 SMPS4 A10
     * ADC12BMEM13 = VLED5 SMPS5 A11
     * ADC12BMEM14 = VLED4 SMPS6 A6
     * TEMP1 P1.0
     * TEMP2 P1.2
     * TEMP3 P3.1
     * TEMP4 P3.3
     * TEMP5 P1.4
     * LIGHT1 P1.1
     * LIGHT2 P3.0
     * LIGHT3 P3.2
     * VLED1 P1.5
     * VLED2 P4.0
     * VLED3 P4.1
     * VLED4 P4.2
     * VLED5 P4.3
     * VLED6 P2.3
     */
    
    /*Original Texas copyright although there's not that much left of the original example..*/
    
    /* --COPYRIGHT--,BSD
     * Copyright (c) 2016, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    
    #include "driverlib.h"
    #include "as3824.h"
    #include "stdio.h"
    #include "string.h"
    #include "stdlib.h"
    
    #include "ADC_Lookup.h"
    
    #define USHORT uint16_t
    #define SHORT int16_t
    #define UCHAR uint8_t
    #define CHAR int8_t
    #define ULONG uint32_t
    #define LONG int32_t
    #define VALX 15
    #define VALY 8
    #define LIGHTRES 2200
    
    void Init_Adc();
    void Init_Adc_Ports();
    void Init_Adc_Mem(UCHAR memory, UCHAR input, USHORT sequence);
    void Convert_Sensor(char values[][VALY], UCHAR valx, UCHAR valy);
    char * Convert_Temp(USHORT sensor);
    char * Convert_Light(USHORT sensor);
    
    /*
    extern USHORT * ADCTEMP;
    extern USHORT ADCLOOKUP;
    */
    
    
    USHORT temp;
    volatile USHORT sensors[16]={0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0,
    	0
    };
    
    void main(void)
    {
        // Stop WDT
        WDT_A_hold(WDT_A_BASE);
    /*
     * Setup ADC ports
     */
        Init_Adc_Ports();
    
        /*
         * Disable the GPIO power-on default high-impedance mode to activate
         * previously configured port settings
         */
        PMM_unlockLPM5();
    /*
     * Setup ref voltage to 2.5V
     */
        Ref_A_setReferenceVoltage(REF_A_BASE, REF_A_VREF2_5V);
    
    /*
     * Setup ADC
     */
        Init_Adc();
    
    
        while(1)
        {
        	static char values[VALX][VALY];
        	static UCHAR valx, valy;
        	valx=sizeof(values)/sizeof(values[0]);
        	valy=sizeof(values[0])/sizeof(values[0][0]);
            __delay_cycles(5000);
    
            //Enable/Start sampling and conversion
            /*
             * Base address of ADC12B Module
             * Start the conversion into memory buffer 0
             * Use the sequence of channels, single-conversion mode
             */
            ADC12_B_startConversion(ADC12_B_BASE,
                                    ADC12_B_MEMORY_0,
    								ADC12_B_SEQOFCHANNELS);
    
            __bis_SR_register(LPM0_bits + GIE);     // LPM0, ADC12_B_ISR will force exit
            __no_operation();                       // For debugger
            Convert_Sensor(values, valx, valy);
    /*        printf("TEMPI %x, TEMP1 %x, TEMP2 %x, TEMP3 %x, TEMP4 %x, TEMP5 %x, LIGHT1 %x, LIGHT2 %x, LIGHT3 %x\n"
            		 "VLED1 %x, VLED2 %x, VLED3 %x, VLED4 %x, VLED5 %x, VLED6 %x \n",
            		sensors[0],sensors[1],sensors[2],sensors[3],sensors[4],sensors[5],sensors[6],sensors[7],
    				sensors[8],sensors[9],sensors[10],sensors[11],sensors[12],sensors[13],sensors[14]);
    				*/
        }
    }
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=ADC12_VECTOR
    __interrupt
    #elif defined(__GNUC__)
    __attribute__((interrupt(ADC12_VECTOR)))
    #endif
    void ADC12_ISR(void)
    {
        switch(__even_in_range(ADC12IV,40))
        {
        case  0: break;                         // Vector  0:  No interrupt
        case  2: break;                         // Vector  2:  ADC12BMEMx Overflow
        case  4: break;                         // Vector  4:  Conversion time overflow
        case  6: break;                         // Vector  6:  ADC12BHI
        case  8: break;                         // Vector  8:  ADC12BLO
        case 10: break;                         // Vector 10:  ADC12BIN
        case 12:                                // Vector 12:  ADC12BMEM0 Interrupt
        	sensors[0] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_0);
            break;                              // Clear CPUOFF bit from 0(SR)
        case 14:	                          // Vector 14:  ADC12BMEM1
        	sensors[1] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_1);
        	break;
        case 16:                          // Vector 16:  ADC12BMEM2
        	sensors[2] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_2);
        	break;
        case 18:                          // Vector 18:  ADC12BMEM3
        	sensors[3] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_3);
        	break;
        case 20:                          // Vector 20:  ADC12BMEM4
        	sensors[4] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_4);
    		break;
        case 22:                          // Vector 22:  ADC12BMEM5
        	sensors[5] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_5);
        	break;
        case 24:                          // Vector 24:  ADC12BMEM6
        	sensors[6] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_6);
        	break;
        case 26:                          // Vector 26:  ADC12BMEM7
        	sensors[7] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_7);
        	break;
        case 28:                          // Vector 28:  ADC12BMEM8
        	sensors[8] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_8);
        	break;
        case 30:                          // Vector 30:  ADC12BMEM9
        	sensors[9] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_9);
        	break;
        case 32:                          // Vector 32:  ADC12BMEM10
        	sensors[10] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_10);
        	break;
        case 34:                          // Vector 34:  ADC12BMEM11
        	sensors[11] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_11);
        	break;
        case 36:                          // Vector 36:  ADC12BMEM12
        	sensors[12] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_12);
        	break;
        case 38:                          // Vector 38:  ADC12BMEM13
        	sensors[13] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_13);
        	break;
        case 40:                   				// Vector 40:  ADC12BMEM14
        	sensors[14] = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_14);
        	__bic_SR_register_on_exit(LPM0_bits);   // last in sequence, Exit active CPU
        	break;
        default: _never_executed();
        }
    }
    
    void Init_Adc(void){
        //Initialize the ADC12B Module
        /*
         * Base address of ADC12B Module
         * Use internal ADC12B bit as sample/hold signal to start conversion
         * USE MODOSC 5MHZ Digital Oscillator as clock source
         * Use default clock divider 5 => 1MHz ADC clock
         * Not use internal channel
         */
        ADC12_B_initParam initParam = {0};
        initParam.sampleHoldSignalSourceSelect = ADC12_B_SAMPLEHOLDSOURCE_SC;
        initParam.clockSourceSelect = ADC12_B_CLOCKSOURCE_ADC12OSC;
        initParam.clockSourceDivider = ADC12_B_CLOCKDIVIDER_5;
        initParam.clockSourcePredivider = ADC12_B_CLOCKPREDIVIDER__1;
        initParam.internalChannelMap = ADC12_B_TEMPSENSEMAP;
        ADC12_B_init(ADC12_B_BASE, &initParam);
    
        //Enable the ADC12B module
        ADC12_B_enable(ADC12_B_BASE);
    
        /*
         * Base address of ADC12B Module
         * For memory buffers 0-7 sample/hold for 64 clock cycles
         * For memory buffers 8-15 sample/hold for 4 clock cycles (default)
         * Disable Multiple Sampling
         * We need 30us conversion time for temperature sensor so 32 cycles
         */
        ADC12_B_setupSamplingTimer(ADC12_B_BASE,
                                   ADC12_B_CYCLEHOLD_64_CYCLES,
                                   ADC12_B_CYCLEHOLD_4_CYCLES,
                                   ADC12_B_MULTIPLESAMPLESENABLE);
    
        Init_Adc_Mem(ADC12_B_MEMORY_0, ADC12_B_INPUT_TCMAP, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_1, ADC12_B_INPUT_A0, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_2, ADC12_B_INPUT_A2, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_3, ADC12_B_INPUT_A13, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_4, ADC12_B_INPUT_A15, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_5, ADC12_B_INPUT_A4, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_6, ADC12_B_INPUT_A1, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_7, ADC12_B_INPUT_A12, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_8, ADC12_B_INPUT_A14, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_9, ADC12_B_INPUT_A5, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_10, ADC12_B_INPUT_A8, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_11, ADC12_B_INPUT_A9, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_12, ADC12_B_INPUT_A10, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_13, ADC12_B_INPUT_A11, ADC12_B_NOTENDOFSEQUENCE);
        Init_Adc_Mem(ADC12_B_MEMORY_14, ADC12_B_INPUT_A6, ADC12_B_ENDOFSEQUENCE);
    
        ADC12_B_clearInterrupt(ADC12_B_BASE,
                               0,
                               0xFFFF
                               );
        ADC12_B_clearInterrupt(ADC12_B_BASE,
                               1,
                               0xFFFF^ADC12_B_IFG15
                               );
        //Enable memory buffer 0-14 interrupts
        ADC12_B_enableInterrupt(ADC12_B_BASE,
                                0xFFFF^ADC12_B_IE15,
                                0,
                                0);
    };
    
    /*
     * Setup pins related to ADC
     */
    void Init_Adc_Ports(){
        //Set ADC ports as ternary function inputs
        /*
    
         * Select Port 1
        * Set Pins 0,1,2,4 and 5 to input Ternary Module Function, (A0-5, C1, VREF+, VeREF+).
         */
        GPIO_setAsPeripheralModuleFunctionInputPin(
            GPIO_PORT_P1,
            GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN4+GPIO_PIN5,
            GPIO_TERNARY_MODULE_FUNCTION
            );
        /*
        * Select Port 2
        * Set Pin 3 input Ternary Module Function, (A6, C1, VREF+, VeREF+).
        */
       GPIO_setAsPeripheralModuleFunctionInputPin(
           GPIO_PORT_P2,
           GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3,
           GPIO_TERNARY_MODULE_FUNCTION
           );
        /*
        * Select Port 3
        * Set Pins 0,1,2,3 input Ternary Module Function, (A12-15)
        */
       GPIO_setAsPeripheralModuleFunctionInputPin(
           GPIO_PORT_P3,
           GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3,
           GPIO_TERNARY_MODULE_FUNCTION
           );
    
       /*
       * Select Port 4
       * Set Pins 0,1,2,3 input Ternary Module Function, (A8-11).
       */
      GPIO_setAsPeripheralModuleFunctionInputPin(
          GPIO_PORT_P4,
          GPIO_PIN0+GPIO_PIN1+GPIO_PIN2+GPIO_PIN3,
          GPIO_TERNARY_MODULE_FUNCTION
          );
    };
    
    void Init_Adc_Mem(UCHAR memory, UCHAR input, USHORT sequence){
        //Configure Memory Buffer
        /*
         * Base address of the ADC12B Module
         * Configure memory buffer x
         * Map input z to memory buffer x
         * Vref+ = AVcc
         * Vref- = AVss
         * Memory buffer x is (not) the end of a sequence
         */
        ADC12_B_configureMemoryParam configureMemoryParam = {0};
        configureMemoryParam.memoryBufferControlIndex = memory;
        configureMemoryParam.inputSourceSelect = input;
        configureMemoryParam.refVoltageSourceSelect =
        	ADC12_B_VREFPOS_INTBUF_VREFNEG_VSS;
        configureMemoryParam.endOfSequence = sequence;
        configureMemoryParam.windowComparatorSelect =
            ADC12_B_WINDOW_COMPARATOR_DISABLE;
        configureMemoryParam.differentialModeSelect =
            ADC12_B_DIFFERENTIAL_MODE_DISABLE;
        ADC12_B_configureMemory(ADC12_B_BASE, &configureMemoryParam);
    }
    
    void Convert_Sensor(char values[][VALY], UCHAR valx, UCHAR valy){
    	char * result;
    	if (sensors[0]<0x3D7) {
    		strcpy((char *) values[0],"LOW\0");
    	}
    	else{
    		/*
    		 * Internal sensor has closed formula for temperature
    		 * 1 degree = 4.096 ADC units
    		 */
    		ltoa(((((ULONG)sensors[0]-0x3D7)*1000)>>12)-40, values[0]);
    		/*
    		printf("TEMPi %s\n", values[0]);
    		*/
    	};
    	strcpy (values[3], Convert_Temp(sensors[3]));
    	strcpy (values[4], Convert_Temp(sensors[4]));
    	strcpy (values[5], Convert_Temp(sensors[5]));
    	strcpy (values[8], Convert_Light(sensors[8]));
    	printf("TEMPi,%s,�C,TEMP3,%s,�C,TEMP4,%s,�C,TEMP5,%s,�C,LIGHT3,%s,Lux\n", values[0],values[3],values[4],values[5],values[8]);
    }
    
    char * Convert_Temp(USHORT sensor){
    	static char result[8];
    	SHORT i=0;
    	/*memset(result, '\0', 8);*/
    	/*
    	 * This means we're out of bounds i.e. cooking
    	 */
    	if(ADCTEMP[ADCLOOKUP-1]>sensor){
    		strcpy("HOT\0", result);
    	}
    	else{
    		/*
    		 * Out of bounds in the opposite direction
    		 */
    		if(ADCTEMP[0]<sensor){
    			strcpy("LOW\0", result);
    		}
    		else{
    			/*
    			 * Lookup table has 128 entries so we hop in increments of 16 up to 8 times until we're
    			 * beyond sensor value, then come back again until we cross over again or hit zero
    			 */
    			for(i=0; i<=ADCLOOKUP; i=i+16){
    				/*
    				 * Is our target value in last 16 values?
    				 */
    				if(ADCTEMP[i-1]<=sensor){
    					/*
    					 * Keep rolling back until we hit target value
    					 */
    					for(;i>-1;i--){
    						if(ADCTEMP[i]>=sensor){
    							break;
    						}
    					}
    					ltoa((long) i, result);
    					break;
    				}
    			}
    		}
    
    	}
    	return result;
    }
    
    char * Convert_Light(USHORT sensor){
    	/*
    	 * The actual formula is ADC*Vref / 0.4uA * 1.05 * res * 4096 but no damn reason to
    	 * calculate it every time
    	 * coefficient 2.5 * (1/(0.4uA * 1.05 * 4096))= 1453.218, multiply by 512 to ~ 744048
    	 */
    	static char result[8];
    	ULONG value=0;
    	ULONG coeff=744048;
    	/*memset(result,'\0',8);*/
    	value=(sensor*coeff)>>9;
    	value=value/LIGHTRES;
    	ltoa(value, result);
    	return result;
    }
    

  • *cough*

    Can you replicate my issue?
  • Olli,

    I'm working on getting experts familiar with this subject to address your question, but this may take sometime due to the Thanksgiving Holidays (US) this week.Please stand by.
  • Hi,

    Olli Mannisto said:
    I have a source file that defines a lookup table which I left as a .c file although it could just as well be a header file. If I convert that to header and remove the extern references from the main program this problem goes away. This sound like a known issue? 

    I couldn't reproduce this issue using your source files as-is using CCSv6.2.00050, MSP430 support component version 6.3.4.6 and my FR5969 Launchpad Rev 2.0. Please check the attached project I created based on the Driverlib emptyproject directly from the TI Resource Explorer:

    As a general statement you could perhaps try to go through the troubleshooting steps for the General IDE and the Debugger mentioned in the wiki page below. These tend to help with these very uncommon and unexpected errors.

    http://processors.wiki.ti.com/index.php/Troubleshooting_CCSv6 

    I don't have an exact explanation as to why the code changes are confusing the debugger, since I couldn't reproduce it here. 

    Hope this helps,

    Rafael

    emptyProject.zip

  • Hei,

    This problem "went away" at some point but instead I got a problem with printf generating spurious breakpoint in debugger. e2e.ti.com/.../563445

    Something funny in my CCS debugging and yeah, I've wiped out the workspace etc. I get that latest problem on two different computers too.

**Attention** This is a public forum