X2.4 My cheat sheet for  programming MSP430 in C language.

 
  FOR

  Spelling and replacement only.

 
for (;;)                                 // Endless cycle
{
for (i = 10; i > 0; i--);           // Delay 10x
for (i = 0; i < 0xfffe; i++);    // Delay (0xfffe = 65534)

for (i = 1000; i > 0; i--);       // Delay 1000x
__delay_cycles(1000);     // Replacement  for "Delay 1000x"
}


  Delay in processor cycles (MCLK). If your processor runs at a frequency of 1 MHz, then the delay in executing command "__delay_cycles(1000000)" will be, precisely, one second.



  * Additional from slau132m.pdf, MSP430 Optimizing 'C/C++' Compiler:

  void __delay_cycles(unsigned long);

  The __delay_cycles intrinsic inserts code to consume precisely the number of specified cycles with no side effects. The number of cycles delayed must be a compile-time constant.











16.02.2020  SKootS

_

 
 

Make a free website with Yola