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 v6

Other Parts Discussed in Thread: MSP430FG4618, TEST2

Hi,

I'm using MSP430FG4618 and I want to communicate with RFID through SPI.  If I'm using "Debugger with Step Over" program is okay but  with "Resume" program does not work! Any Suggestion?

Thx

Admir

  • Hello Admir,

    Using the term "program does not work" is very broad, can you define exactly what part of your code or which peripheral is not working? What symptom proves that operation is not as expected? You need to isolate the code/peripheral that is not working correctly in order to gain insight on what is wrong with it. Stepping over code takes a lot longer than quickly running though the code and it makes me think that timing is an issue here, perhaps not giving time for a clock or LFXT time to settle before beginning main operation.

    Regards,
    Ryan
  • Hello Ryan,

    I'm using UART1 -> MSP430FG4618. My source code is here (I'm using SPI to communicate with RFID board):

    void main(void) {
    long int i;
    volatile unsigned int RFID_AKTIV = 0;
    volatile unsigned int RFID_ECHO = 0;
    volatile unsigned int RFID_PROT = 0;
    volatile unsigned int PROTOKOL_S = 0;
    volatile unsigned int k=0x00;
    volatile unsigned OL=0x00;
    volatile int daten=0x00;
    volatile unsigned int test=0;
    volatile unsigned int test2=0;
    volatile unsigned int test3=0;

    WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
    FLL_CTL0 |= XCAP14PF; // Configure load caps

    initLCD_A(); // Initialize LCD_A
    dispAllLCDSegs(); //Test
    //for(i=10000;i>0;i--);
    clrLCD(); //Leeren
    dispChar(0,9);

    // Wait for xtal to stabilize
    do
    {
    IFG1 &= ~OFIFG; // Clear OSCFault flag
    for (i = 0x47FF; i > 0; i--); // Time for flag to set
    }
    while ((IFG1 & OFIFG)); // OSCFault flag still set?

    for(i=2100;i>0;i--); // Now with stable ACLK, wait for
    /***********************************************************************************/
    /*Port Initialisierung*/
    //LED -> zur Info..LED wird angemacht, wenn ECHO in Ordnung ist.
    P2DIR |=BIT1;
    P2OUT &=~BIT1;
    /*****SPI Initialisierung*****/
    //CS
    P4OUT |= BIT6;
    P4DIR |= BIT6;
    //IRQ
    P4OUT |=BIT2;
    P4DIR |=BIT2;
    //MOSI
    P4DIR |= BIT3;
    P4SEL |= BIT3;
    //MISO
    P4DIR &=~BIT4;
    P4SEL |= BIT4;
    //CLK
    P4DIR |= BIT5;
    P4SEL |= BIT5;
    /* USART1 Control Register*/
    //CHAR - 8 bits, SYNC - SPI mode, MM - Master, SWRST enable Veränderung
    U1CTL = MM+SWRST;
    U1CTL |= CHAR;
    U1CTL |= SYNC;
    U1CTL |= SPB;
    /*Transmit Control Register*/
    //CKPL - Clock Polarity, SSEL1 - ACLK Taktgeber, STC STC Enable
    U1TCTL &= ~CKPL;
    U1TCTL |= CKPH;
    U1TCTL |= SSEL1;
    U1TCTL |= STC;
    U1TCTL |= URXSE;
    /*Baud Rate*/
    U1BR0 = 0x080;
    U1BR1 = 0x000;
    U1MCTL = 0x000;
    /*Modul anmachen*/
    //USPIE1 - Enable URXE1 und UTXE1
    ME2 |= USPIE1;
    /*zum Schluss*/
    U1CTL &= ~SWRST;
    /*****************************************************SPI angemacht*/
    __bis_SR_register(GIE);
    /*RFID Click aktivieren*/
    RFID_AKTIV = aktivazion();
    /*RFID Click ECHO*/
    while(RFID_ECHO == 0){
    i=0;


    //ECHO --->
    P4OUT &= ~BIT6; //CS
    while (!(IFG2 & UTXIFG1));
    U1TXBUF = 0x00;
    while (!(IFG2 & UTXIFG1));
    U1TXBUF = 0x55;
    P4OUT |= BIT6; // CS
    /*******************/

    //Pooling
    P4OUT &=~BIT6; //CS
    while(k!=0x01 & i<10){
    while (!(IFG2 & UTXIFG1));
    U1TXBUF = 0x03;
    k=((U1RXBUF & 0x08)>>3) & 0x01;
    i++;
    }
    k=0;
    P4OUT |=BIT6; //CS

    //Lesen
    P4OUT &= ~BIT6; //CS
    while (!(IFG2 & UTXIFG1));
    U1TXBUF = 0x02;
    while (!(IFG2 & UTXIFG1));
    U1TXBUF = 0x03;
    P4OUT |= BIT6; // CS
    while (!(IFG2 & URXIFG1));
    daten = U1RXBUF;
    if(daten==0x55 || daten ==0x81){
    P2OUT ^=BIT1; //ECHO in Ordnung
    }
    RFID_AKTIV = aktivazion();
    }
    RFID_PROT = protokoll();
    while(RFID_PROT == 0)
    RFID_PROT = protokoll();
    /*--------------------------------------------------------------------------------------*/
    }

    Regards,
    Admir
  • Admir,

    If you can, please put a breakpoint before the xtal stabilization loop and run your code to this breakpoint, allow the breakpoint to stop the MCU, then resume operation. Optionally step up to this breakpoint before resuming operation. Also perform this test with a breakpoint placed after the stable ACLK for loop and report if any of these tests alter your results.

    Your code set up is quite strange and this could be a factor in the issue described. Usually variables are defined outside of the main function and I do not see an inclusion of msp430.h. Also, where is your main loop located to ensure that the main function is not exited at any given time? Your program should not be allowed to leave main.

    Regards,
    Ryan
  • Hello Ryan,

    I have tested with breakpoints but it is the same. Without success! In "Board.h" I have included "msp430xG46x.h".

    Regards,
    Admir
  • Admir,

    We still have to find the section of your code that is breaking the program. Continue using breakpoints to divide your code into sections and try to find the part of your code that is causing the failure if not stepped through manually. And please add the line while(1) __no_operation(); to the end of your main function.

    Regards,
    Ryan
  • Hi,

    I have solved the problem. In the picture are CS (chip select - yellow) and SCK (takt quele - blue).

    For example:

    Code

    //ECHO --->

    P4OUT &= ~BIT6; //CS

    while (!(IFG2 & UTXIFG1));

    U1TXBUF = 0x00;

    while (!(IFG2 & UTXIFG1));

    U1TXBUF = 0x55;

    P4OUT |= BIT6; // CS

    /*******************/

    and effect is in the picture. Problem was with CS! CS comes to early on high! I do not know why.

    Solution is:

    P6OUT &= ~BIT0; //CS

    while (!(IFG2 & UTXIFG1));

    U1TXBUF = 0x00;

    while (!(IFG2 & UTXIFG1));

    U1TXBUF = 0x55;

    __delay_cycles (75000);

    P6OUT |= BIT0; // CS

    and with "__delay_cycles()" before "P6OUT |=BIT0" the SPI is OK.

    Regards,

    Admir

**Attention** This is a public forum