hi all,
just started getting my head around the MSP430 and failed at the first hurdle...
I've got a very basic program which does little at the moment, targetted to a MSP430G2131 on the Launchpad. In short, the program isn't running. When stepping through on the debugger, it gets as far as initialising a global variable then blows up with:
Can't find a source file at "/db/ztree/library/trees/gep/gep-d17x/src/ti/targets/msp430/rts430/boot_3.3.c"
The linker has been configured to give a 64byte stack and 64byte heap space (although various other configurations have been attempted), the main code is:
/* * ======== Standard MSP430 includes ======== */#include <msp430.h>/* * ======== Grace related includes ======== */#include <ti/mcu/msp430/csl/CSL.h>/* GLOBALS */unsigned char gPulseIdx;unsigned long gPulse;typedef enum{ eIDLING, eCAPTURED} STATE;STATE gState;/* * ======== main ======== */int main(int argc, char *argv[]){ int i; unsigned short u; CSL_init(); // Activate Grace-generated configuration __bis_SR_register(LPM0_bits + GIE); //enable interrupt //local inits gPulseIdx = 0; //>>DEBUGGER BLOWS UP HERE<< //process loop for(;;) { switch (gState) { case eIDLING: break; case eCAPTURED: u = gPulse; } } return (0);}
I'm almost certain its a memory allocation problem. The programs been repeatedly disappearing at this point, but only after clearing down the memory allocation have I now actually got an error!
Q> any ideas why it might be blowing up
Q> any ideas how to get the RAM allocation size from the linker?
Q> does the grace configuration add overhead to RAM size - i.e. should GRACE be avoided for such small memory devices?
Any comments/suggestions appreciated!
(CCS v5.1.1.00031)
Mat
Mathew MaherWhen stepping through on the debugger, it gets as far as initialising a global variable then blows up with:
Mathew MaherQ> any ideas how to get the RAM allocation size from the linker?
Good spot with the ISR enable. I'll have a play and see if removing that line resolves the problem. Copied grace config below. Bit strange: the grace config specifies stack/heap sizes, but I can't find anything under grace itself to specify these, instead have set them in linker properties. Which takes precidence: linker properties or grace config?
/** * @fileOverview Grace *//* need to use the CSL module to generate the CSL code */var CSL = xdc.useModule('ti.mcu.msp430.csl.CSL');var USI = xdc.useModule('ti.mcu.msp430.csl.communication.USI');var Timer_A2 = xdc.useModule('ti.mcu.msp430.csl.timer.Timer_A2');var Flash = xdc.useModule('ti.mcu.msp430.csl.memory.Flash');CSL.configApiVersion = "1.00.00";/* these modules should be part of every project */var WDTplus = xdc.useModule('ti.mcu.msp430.csl.watchdog.WDTplus');var GPIO = xdc.useModule('ti.mcu.msp430.csl.gpio.GPIO');var BCSplus = xdc.useModule('ti.mcu.msp430.csl.clock.BCSplus');var System = xdc.useModule('ti.mcu.msp430.csl.system.System');/* set stack and heap sizes as appropriate for MSP430 */Program.sysStack = 0;Program.stack = 64;Program.heap = 0;Program.argSize = 0;/* Enable global interrupt */System.srRegs.SR.GIE = System.srDefs.GIE;BCSplus.regs.LFXT1CLKHz = 32768.0;BCSplus.regs.BCSCTL3.LFXT1S = BCSplus.defs.LFXT1S_0;BCSplus.regs.BCSCTL1.DIVA = BCSplus.defs.DIVA_0;USI.showSelectionPage = false;USI.regs.USICTL0.USIMST = USI.defs.USIMST;USI.usiEnabled = true;USI.regs.USICTL0.USIPE5 = USI.defs.USIPE5;USI.regs.USICTL0.USIPE7 = USI.defs.USIPE7;USI.regs.USICTL0.USIPE6 = USI.defs.USIPE6;USI.regs.USICTL0.USIOE = USI.defs.USIOE;Timer_A2.regs.TACTL.TASSEL = Timer_A2.defs.TASSEL_1;Timer_A2.txClkPin[0] = 0;Timer_A2.inputClockToTimer = 32.768;Timer_A2.regs.TACTL.ID = Timer_A2.defs.ID_0;Timer_A2.regs.TACTL.MC = Timer_A2.defs.MC_2;Timer_A2.ccrXTimerSelection_PowerUser[1] = xdc.module("ti.mcu.msp430.csl.timer.ITimer").CCRxTimerSelection_PowerUser_Selection_2;Timer_A2.ccrXTimerSelection_BasicView[1] = xdc.module("ti.mcu.msp430.csl.timer.ITimer").CCRxTimerSelection_BasicView_Selection_2;Timer_A2.regs.TACCR1 = 442;Timer_A2.regs.TACCTL1.CAP = Timer_A2.defs.CAP;Timer_A2.regs.TACCTL1.SCS = Timer_A2.defs.SCS;Timer_A2.ccInputPin[1] = 1;GPIO.regs.P1SEL.Bit2 = GPIO.defs.BIT2;Timer_A2.regs.TACCTL1.CM = Timer_A2.defs.CM_1;Timer_A2.regs.TACCR0 = 0;Timer_A2.regs.TACCTL1.CCIE = Timer_A2.defs.CCIE;Timer_A2.ccr1InterruptHandler = "TimerA2_ISR";BCSplus.userInputDCO = 1000.0;BCSplus.regs.BCSCTL1.RSEL3 = BCSplus.defs.RSEL3;BCSplus.regs.DCOCTL.MOD4 = BCSplus.defs.MOD4;BCSplus.regs.DCOCTL.MOD2 = BCSplus.defs.MOD2;WDTplus.regs.WDTCTL.WDTHOLD = WDTplus.defs.WDTHOLD_OFF;WDTplus.regs.WDTCTL.WDTSSEL = WDTplus.defs.WDTSSEL;WDTplus.wdtHandler = "Watchdog_ISR";System.ie1Regs.IE1.WDTIE = System.ie1Defs.WDTIE;
Mathew Maherthe grace config specifies stack/heap sizes
One more thing: it makes no sense to define main with parameters or return from main.
Since there is no OS that can pass parameters or where you can return to, the definition of main should bevoid main (void)(Well, some compilers insist on a return type of int for main, but it has no meaning.)
Ending main with return(0) is nonsense. You should enter LPM4 instead if there's really nothing to be done ever again (until power cycle)(Some compilers generate code that enters LPM4 when you really return from main, but this is compiler specific and not portable)
_____________________________________Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.
Jens-Michael GrossEnding main with return(0) is nonsense.
nt main(int argc, char *argv[]) { CSL_init(); // Activate Grace-generated configuration // >>>>> Fill-in user code here <<<<< return (0); }
Jens-Michael Gross(Some compilers generate code that enters LPM4 when you really return from main, but this is compiler specific and not portable)
void abort(void) { /*-------------------------------------------------------------------*/ /* SET C$$EXIT LABEL SO THE DEBUGGER KNOWS WHEN THE C++ PROGRAM HAS */ /* COMPLETED. THIS CAN BE REMOVED IF THE DEBUGGER IS NOT USED. */ /*-------------------------------------------------------------------*/ __asm(" .global C$$EXIT"); __asm("C$$EXIT: nop"); for (;;); /* SPINS FOREVER */ }
<
> Not exactly low power!
When I tried to compile a program with the posted GRACE configuration and the C code the following linker errors occured:
undefined first referenced symbol in file --------- ---------------- TimerA2_ISR C:\DOCUME~1\workspace_v5_1\GRACE_timer\src\csl/csl.lib<CSL_init.obj> Watchdog_ISR C:\DOCUME~1\workspace_v5_1\GRACE_timer\src\csl/csl.lib<CSL_init.obj>error #10234-D: unresolved symbols remain
Problem solved!
It was indeed the call to the interrupt enable. GRACE has already enabled these interrupts, but for some reason re-enabling them causes problems. From my point of view, it's simply a case of removing that line and everything works.
I didn't post the whole code because it's pretty irrelevant and would just swamp the posting, but here they are:
void TimerA2_ISR(){ _NOP();}void Watchdog_ISR(){ _NOP();}:
The main/return thing - it's good to hear what I was suspecting, but I didn't change it because, as the previous post confirms, the CCS wizard produces this code (I assumed it had good reason for doing this).
Thanks for your support!
Mathew MaherGRACE has already enabled these interrupts, but for some reason re-enabling them causes problems.
For example: I don't know what TimerA2_ISR is supposed to do. But if it is the TIMER2_A1_Vector, and the code does not reset the IFG bit inside the ISR, this will cause an eternal ISR loop and main is effectively stopped.
Mathew Maher the CCS wizard produces this code (I assumed it had good reason for doing this).