LIB C Func., MSP430GF.


How to connect LaunchPad with MSP430F2011



set/reset/toggle


for/do/while

 while(1)
  {
    P1OUT |= 0x02;         // P1.1 = 1

    P1OUT &= ~0x02;      // P1.1 = 0

    P1OUT ^= 0x01;       // Toggle P1.0
  }
for (;;)
  {
for (i = 10; i > 0; i--);          // Delay 1x
for (i = 1000; i > 0; i--);       // Delay 100x
for (i = 0; i < 0xfffe; i++);    // Delay
  }     
do (i--);
while (i != 0);


switch/case



if/while

switch (selected)
{
    case 0:
    {
        break;
    }
    case 1:
    {
        break;
    }
    default: break;
}


#include <msp430.h>
  volatile unsigned int i;
int main(void)
{

   if (CALBC1_1MHZ==0xFF)
  {                                            
    while(1); 
  }

    if ((CAOUT & CACTL2)) P1OUT |= 0x01;
    else P1OUT &= ~0x01;


pointers



pointers

  void write_SegC (char value)
{
  char *Flash_ptr;                   // Flash pointer

  Flash_ptr = (char *) 0x1040;  // Init. Flash pointer
  *Flash_ptr = 0;       // Write to erase Fl. segment

  for (i=0; i<64; i++)
  {
    *Flash_ptr++ = value;     // Write value to flash
  }

((void (*)())0x170)(); // "call to #0170h"
}

 void copy_C2D (void)
{
  char *Flash_ptrC;  // Segment C pointer
  char *Flash_ptrD;  // Segment D pointer

  Flash_ptrC = (char *) 0x1040; // Init. Fl. pointer
  Flash_ptrD = (char *) 0x1000; //
Init. Fl. pointer
  *Flash_ptrD = 0;
// Write to erase Fl. segment
  for (i=0; i<64; i++)
  {
// copy value segment 0x1040 to segment 0x1000    *Flash_ptrD++ = *Flash_ptrC++;
  }
}

vars


char  value;                        // 8-bit value

unsigned char BitCnt;

char *flash_ptr;                   // pointer

char *Flash_ptrA;                // pointer

unsigned int RXTXData;

volatile unsigned int i;  //volatile to prev. removal

static unsigned int LastADCVal;

long temp;
long IntDegF;
long IntDegC;



/* --- Сделано, исключительно, как справочная страничка. --- */



2.03.2016  SKootS

_

Make a Free Website with Yola.