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/MSP430FR5969: Printf causes a breakpoint

Part Number: MSP430FR5969

Tool/software: Code Composer Studio

I know printf uses a breakpoint to do it's job. However it's halting the debugger too! In my case it gets stuck to line 114 in trgmsg.c. Breakpoint is not visible in the breakpoint list btw. 

Is this a common problem?

I have done due diligence with the wiki page.. Stack and heap is boosted, CIO is enabled, stdio.h included, et cetera. Printf *works* just fine, except for that breakpoint. 

  • The code composer version is 

    Code Composer Studio

    Version: 6.2.0.00050

    The project is too extensive now to post here but I can send it if needed..

  • Olli,

    I think we are going to need the project to try to figure out what is going on. If you like prefer you can zip it up and send it to me via a private message. If you click on my name it should give you the option to send me a message. I will also send you a friend request.

    I am off next week but I can take a 5969 LaunchPad home with me and see if I can reproduce the issue.

    Regards,
    John
  • Hei,

    I was away for holidays myself, back in the office today.. I sent you the source code, debug messages should work without the associated hardware except that you should get ones/zeros instead of valid values.

    Regards, Olli
  • Olli,

    I can reproduce the issue. At first I put a printf just before your call to Setup(). That works fine and does not remain halted. However as soon as I put a printf inside the while(1) loop I get the issue you are seeing where it halts inside the printf code. I removed the printf before Setup() to see if it was related to the number of breakpoints but it still halts.

    We should have enough to figure out what is going on. At this point I think something in the code of Setup() is causing the debugger misbehavior. Thanks for sending the project.

    I can reproduce the issue in both CCS6.1.0 and CCSv7.0.0.

    Regards,
    John
  • Setup() sets a number of timers and ISRs so presumably one of those might have a knock-on effect.
  • I had a minute to look at this. The problem is "caused" by setting an FRAM waitstate in clock init. 

    If you have 16MHz DCO and waitstate=1, you get spurious breakpoint.

    If you have 8MHz DCO and waitstate=1, you get a spurious breakpoint.

    If you have 8MHz DCO and waitstate=0, spurious breakpoint goes away. 

    8MHz DCO + waitstate = 2 => spurious breakpoint and so on. 

    Just changing that FRAM waitstate from 0 to 1 makes problem appear in this snippet,  

    CSCTL1 = DCOFSEL_3 | DCORSEL; // Set DCO to 16MHz

    line actually sets the clock to 8MHz, DCOFSEL_4 sets it to 16MHz. We can't obviously have 0 FRAM waitstate with 16MHz however. 

    /* Setup clocks with kludges a plenty 16MHz MCLK 1MHz SMCLK */
    void Init_Clock(){
    	//FRAM needs a wait state for 16MHz
    
    	FRAMCtl_configureWaitStateControl(FRAMCTL_ACCESS_TIME_CYCLES_0);
    	/* Initclocksignal crashes the processor @ 16MHz so we have to use registers the hard way..
    	 * SMCLK 16MHZ / 16 = 1MHz
        */
    
    	CS_initClockSignal(CS_MCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1);
        //Set SMCLK = DCO with frequency divider of 16 = 1MHz
        CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_16);
    
    	/* DCO 16MHz clock workaround code*/
    	uint16_t tempCSCTL3 = 0;
    
    	CSCTL0_H = CSKEY_H; // Unlock CS registers
    	// Assuming SMCLK and MCLK are sourced from DCO
    	// Store CSCTL3 settings to recover later
    	tempCSCTL3 = CSCTL3;
    	/* Keep overshoot transient within specification by setting clk sources
    	to divide by 4*/
    	// Clear the DIVS & DIVM masks (~0x77)and set both fields to 4 divider
    	CSCTL3 = CSCTL3 & (~(0x77)) | DIVS__4 | DIVM__4;
    	CSCTL1 = DCOFSEL_3 | DCORSEL; // Set DCO to 16MHz
    	/* Delay by ~10us to let DCO settle. 60 cycles = 20 cycles buffer +
    	(10us / (1/4MHz))*/
    
    	__delay_cycles(0x60);
    	CSCTL3 = tempCSCTL3; // Set all dividers
    	CSCTL0_H = 0; // Lock CS registers
    	printf("foo!\n");
    }

  • That is great info. I will pass this on to the team looking into it.

    Regards,
    John