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.

no signal from usci module

Other Parts Discussed in Thread: MSP430G2553

hi,

this is the code i have written. of course it is in complete. but at least i have to get start condition right? which i am not getting. so, i request you guys to help me to solve this problem. any little help also would be great. i am stuck in this problem since almost a week. so plz help.

#include<msp430g2553.h>

void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
BCSCTL1 = CALBC1_1MHZ;									//DEFINE THE CLOCK AS 1MHz.
DCOCTL = CALDCO_1MHZ;


/*PORT NITIALIZATION.*/
P1SEL |= BIT6 + BIT7;
P1SEL2 |= BIT6 + BIT7;
P1OUT |= BIT6 + BIT7;
P1REN |= BIT6 + BIT7;
__enable_interrupt();


/* USCI INITIALIZATION.*/
UCB0CTL1 |= UCSWRST;
UCB0CTL0 |= UCMST + UCMODE_3 + UCSYNC;
UCB0CTL1 |= UCSSEL_2 + UCSWRST;
UCB0BR0 = 12;
UCB0BR1 = 0;
UCB0STAT &= ~(UCNACKIFG + UCSTPIFG + UCSTTIFG);
IFG2 &= ~(UCB0TXIFG + UCB0RXIFG);
UCB0CTL1 &= ~UCSWRST;
UCB0I2CIE |= UCNACKIE + UCSTPIE + UCSTTIE;
IE2 |= UCB0TXIE + UCB0RXIE;


/* WRITE.*/
UCB0I2CSA = 0X68;
UCB0CTL1 |= UCTR + UCTXSTT;
while(UCB0CTL1 & UCTXSTT);
while(!(IFG2 & UCB0TXIFG));
while(1);
}


#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCI_TX_ISR (void)
{
IFG2 &= ~UCB0TXIFG;
UCB0TXBUF = 0x00;
}


#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCI_RX_ISR (void)
{
IFG2 &= ~UCB0RXIFG;
}

thnx

  • Hi,

    unfortunately i don't have a G2 with me right know to test exactly what is happening,
    but you must certainly enhance you code in some ways:

    - DO never manipulate IFGs unless you have a good reason,  the UCSWRST does that for you:
    and do not clear the UCB0TXIFG, this one is set to one per default.

    - Do not enable interrupts for which you don't write a proper interrupt vector, you program gets lost:

    UCNAACKIE + UCSTPIE + UCSTTIE.

    I would bet that this last one is the one causing the problem, I'm not sure but i think that interrupt make sens only when in slave mode, and I'm too lazy to read right now....

    Cheers

    NBA

  • hi,

    okay, i disabled UCSTPIE  and UCSTTIE. but UCNAACKIE is needed even in master mode. but still there is some problem.

    i studied that UCB0TXIFG and UCB0RXIFG is related to USCIAB0TX_VECTOR and USCIAB0RX_VECTOR respectively.

    but,

    what about UCNAACKIE??. in which vector it is present.

  • hi,

    I found this statement in user guide. but its quite tricky. i couldn't understand. so please help out.

    "  There are two interrupt vectors for the USCI module in I 2 C mode. One interrupt vector is associated with the transmit and receive interrupt flags. The other interrupt vector is associated with the four state change interrupt flags."

    which are those vectors???

  • hi,

    i found the above statement in user guide of msp430g2553 itself.

     want to know which are the interrupts that appear in USCIAB0TX_VECTOR and USCIAB0RX_VECTOR.

    I also want to know are there any other interrupt vectors other than above ones for uscib0-i2c in msp430g2553???

  • Hi,

    yeah you are right, as a beginner it is hard to find:

    here is how I've done it:

    look into the msp430g2553 datasheet:
    the USCI_A0/USCI_B0 receive @ 0FFEEh which is the USCI_B0 i²c status
    and the USCI_A0/USCI_B0 transmit @0FFECh which is the USCI_B0 i²c receive / transmit.

    Now if you open msp430g2553.h and search for interrupt vector, you will see all interrupt vectors for that device.
    Look for the addresses and you will find  USCIAB0RX_VECTOR => 0FFEEh
    and USCIAB0TX_VECTOR => 0FFECh.

    So handle the i²C status in the USCIAB0RX_VECTOR, and your transmits / receives in the USCIAB0TX_VECTOR

    Check the IFGs within the Service routines to know what actually caused the interrupt....


    BTW, did you finally got your start condition ?

    hope i could help

    NBA

  • Nessim Ben Ammar said:

    So handle the i²C status in the USCIAB0RX_VECTOR, and your transmits / receives in the USCIAB0TX_VECTOR

    hi,

    thnx dude!!!

    it was really helpful.

    finally my code is working.

**Attention** This is a public forum