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.

Random value in MSP430 F5529

I found an example of a random value generator but it says to be for x2xx boards. I still tried it but I got some errors that I don't know I can solve.

int TI_getRandomIntegerFromVLO(void)
{
  unsigned int i;
  int result = 0;
 
  // setup Timer_A
  TA0CCTL1 = CM_1 + CCIS_1 + CAP;
  TA0CTL |= TASSEL__SMCLK + MC__CONTINOUS;
 
  for(i=0 ; i<16 ; i++)
  {
    // shift left result
    result <<= 1;
 
    // wait until Capture flag is set
    while(!(TA0CCTL1 & CCIFG));
 
    // clear flag
    TA0CCTL1 &= ~CCIFG;
 
    // check LSB
    if(TA0CCR1 & 0x01)
    {
      result |= 0x01;
    }
 
    // change the divison of timer input clock
    TA0CTL = (TA0CTL & 0xFCFF) | ((TA0CCR1 & 0x03) << 8);
  }
 
  return result;
}

Description    Resource    Path    Location    Type
‘CAP’ undeclared (first use in this function)    memory_manager.c    /Loader    line 41    C/C++ Problem
‘CCIFG’ undeclared (first use in this function)    memory_manager.c    /Loader    line 49    C/C++ Problem
‘CCIS_1’ undeclared (first use in this function)    memory_manager.c    /Loader    line 41    C/C++ Problem
‘CM_1’ undeclared (first use in this function)    memory_manager.c    /Loader    line 41    C/C++ Problem
‘MC__CONTINOUS’ undeclared (first use in this function)    memory_manager.c    /Loader    line 42    C/C++ Problem
‘TA0CCR1’ undeclared (first use in this function)    memory_manager.c    /Loader    line 56    C/C++ Problem
‘TA0CCTL1’ undeclared (first use in this function)    memory_manager.c    /Loader    line 41    C/C++ Problem
‘TA0CTL’ undeclared (first use in this function)    memory_manager.c    /Loader    line 42    C/C++ Problem
‘TASSEL__SMCLK’ undeclared (first use in this function)    memory_manager.c    /Loader    line 42    C/C++ Problem
gmake: *** [memory_manager.o] Error 1    Loader             C/C++ Problem
gmake: Target `all' not remade because of errors.    Loader             C/C++ Problem

I am still not very familiar with the board, so I wanted to ask if this code is portable to my board, and if so, what should I change to get it working.


Apart from that, what is the idea of this generator ? It is supposed to be running from the beginning of the program and you ask for numbers whenever you need them ? If you start it when you ask for a number isn't it supposed to always return the same value ?

Thank you.

**Attention** This is a public forum