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.

2 little questions



Hello,

First i have a problem with a simple program. (I have the same in a bigger code, so first i tried it in a smaller one..)

First code with if:

#include <msp430G2153.h>

void main(void){

	WDTCTL = WDTPW | WDTHOLD;

	BCSCTL1 = CALBC1_16MHZ;
	DCOCTL = CALDCO_16MHZ;
	
	P1DIR |= BIT0;
	P1SEL = 0x00;

	while(1){
		if(P1IN & BIT1)
			P1OUT |=BIT0;
		else
			P1OUT &= ~BIT0;
	}
}

The picture from osc.:

Second code with an interrupt.

#include <msp430G2153.h>

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
	P1OUT ^= BIT0;
	P1IFG &= ~BIT2;
	P1IES ^= BIT2;
}

void main(void){

	WDTCTL = WDTPW | WDTHOLD;

	BCSCTL1 = CALBC1_16MHZ;
	DCOCTL = CALDCO_16MHZ;

	P1DIR |= BIT0;
	P1SEL = 0x00;
	P1IFG &= ~BIT2;
	P1IE |= BIT2;
	_enable_interrupts ();

	while(1){
	}
}

The picture from the osc.:

My Question: Why is there a little interrupt after the low-high edge?

 

My second question is, when i will compile my code in ccs5 there occurs an error:

"10010 errrors encountered during linking; project.out not built

"#10099-D program will not fit into"

It is only when i have a "if" with more than 2 conditions like: if(a==0 && b==1 && c<=5){}

I am very thankfull for any answers ;)

Best regards

  • I suspect you're tripping over the conditions in section 8.2.7.2 in the User Guide. Summary of that table seems to be that if you request "A->B edge" in the IES and the pin is already at "B", you might get an immediate (stray-ish) interrupt.

    The indicated fix would be to set (change) the IES Before clearing the IFG.

    ----

    Out of context, I'm not sure what those CCS messages are telling you.

  • Hello,

    thank you for your answer, but the problem is unfortunately not solves.

    When i change the settings of ifg like this:

    #include <msp430G2153.h>
    
    #pragma vector=PORT1_VECTOR
    __interrupt void Port_1(void)
    {
    	P1OUT ^= BIT0;
    	P1IES ^= BIT2;
    	P1IFG &= ~BIT2;
    }
    
    void main(void){
    
    	WDTCTL = WDTPW | WDTHOLD;
    
    	BCSCTL1 = CALBC1_16MHZ;
    	DCOCTL = CALDCO_16MHZ;
    
    	P1DIR |= BIT0;
    	P1SEL = 0x00;
    	P1IFG &= ~BIT2;
    	P1IE |= BIT2;
    	_enable_interrupts ();
    
    	while(1){
    	}
    }

    Now first i change the ies, then i delete the ifg.

    But then i have the following signal:

  • hi,

    by writing this statement

    P1IES ^= BIT2;

    you are changing the edge on which the interrupt occurs every time the ISR is called.

    in other words, by a single button press you are triggering 2 interrupts '

    1. one on high- to low transition

    2. the other on low-to high transition

**Attention** This is a public forum