• Main Page
  • Data Structures
  • Files
  • File List
  • Globals

hal_pmm.c

Go to the documentation of this file.
00001 //****************************************************************************//
00002 // Function Library for setting the PMM
00003 //    File: hal_pmm.c
00004 //
00005 //    Texas Instruments
00006 //
00007 //    Version 1.2
00008 //    07/29/09
00009 //
00010 //****************************************************************************//
00011 
00012 
00013 /* ***********************************************************
00014 * THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
00015 * REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
00016 * INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
00017 * FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
00018 * COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
00019 * TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
00020 * POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
00021 * INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
00022 * YOUR USE OF THE PROGRAM.
00023 *
00024 * IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
00025 * CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
00026 * THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
00027 * OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
00028 * OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
00029 * EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
00030 * REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
00031 * OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
00032 * USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
00033 * AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
00034 * YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
00035 * (U.S.$500).
00036 *
00037 * Unless otherwise stated, the Program written and copyrighted
00038 * by Texas Instruments is distributed as "freeware".  You may,
00039 * only under TI's copyright in the Program, use and modify the
00040 * Program without any charge or restriction.  You may
00041 * distribute to third parties, provided that you transfer a
00042 * copy of this license to the third party and the third party
00043 * agrees to these terms by its first use of the Program. You
00044 * must reproduce the copyright notice and any other legend of
00045 * ownership on each copy or partial copy, of the Program.
00046 *
00047 * You acknowledge and agree that the Program contains
00048 * copyrighted material, trade secrets and other TI proprietary
00049 * information and is protected by copyright laws,
00050 * international copyright treaties, and trade secret laws, as
00051 * well as other intellectual property laws.  To protect TI's
00052 * rights in the Program, you agree not to decompile, reverse
00053 * engineer, disassemble or otherwise translate any object code
00054 * versions of the Program to a human-readable form.  You agree
00055 * that in no event will you alter, remove or destroy any
00056 * copyright notice included in the Program.  TI reserves all
00057 * rights not specifically granted under this license. Except
00058 * as specifically provided herein, nothing in this agreement
00059 * shall be construed as conferring by implication, estoppel,
00060 * or otherwise, upon you, any license or other right under any
00061 * TI patents, copyrights or trade secrets.
00062 *
00063 * You may not use the Program in non-TI devices.
00064 //
00065 //This software has been submitted to export control regulations
00066 //The ECCN is EAR99 
00067 * ********************************************************* */
00068 //*****************************************************************************
00081 #include "MSP430.h"
00082 #include "hal_pmm.h"
00083 
00084 
00085 //****************************************************************************//
00086 // Set VCore
00087 //****************************************************************************//
00088 void SetVCore (unsigned char level)
00089 {
00090   unsigned int actlevel;
00091   level &= PMMCOREV_3;                       // Set Mask for Max. level
00092   actlevel = (PMMCTL0 & PMMCOREV_3);         // Get actuel VCore
00093 
00094   while (level != actlevel)
00095   {
00096     if (level > actlevel)
00097       SetVCoreUp(++actlevel);
00098     else
00099       SetVCoreDown(--actlevel);
00100   }
00101 }
00102 
00103 //****************************************************************************//
00104 // Set VCore up
00105 //****************************************************************************//
00106 void SetVCoreUp (unsigned char level)
00107 {
00108   // Open PMM registers for write access
00109   PMMCTL0_H = 0xA5;
00110   // Set SVS/SVM high side new level
00111   SVSMHCTL = SVSHE + SVSHRVL0 * level + SVMHE + SVSMHRRL0 * level;
00112   // Set SVM low side to new level
00113   SVSMLCTL = SVMLFP + SVSLE + SVMLE + SVSMLRRL0 * level;
00114   // Wait till SVM is settled
00115   while ((PMMIFG & SVSMLDLYIFG) == 0);
00116   // Clear already set flags
00117   PMMIFG &= ~(SVMLVLRIFG + SVMLIFG);
00118   // Set VCore to new level
00119   PMMCTL0_L = PMMCOREV0 * level;
00120   // Wait till new level reached
00121   if (PMMIFG & SVMLIFG)
00122   while ((PMMIFG & SVMLVLRIFG) == 0);
00123   // Set SVS/SVM low side to new level
00124   SVSMLCTL = SVSLE + SVSLRVL0 * level + SVMLE + SVSMLRRL0 * level;
00125   // Lock PMM registers for write access
00126   PMMCTL0_H = 0x00;
00127 }
00128 
00129 
00130 //****************************************************************************//
00131 // Set VCore down
00132 //****************************************************************************//
00133 void SetVCoreDown (unsigned char level)
00134 {
00135   PMMCTL0_H = 0xA5;                         // Open PMM module registers for write access
00136   SVSMLCTL = SVSLE + SVSLRVL0 * level + SVMLE + SVSMLRRL0 * level;
00137 //  SVSMLCTL = SVSLE + SVSLRVL0 * level + SVMLE + SVSMLRRL0 * level | SVMLOVPE;  // Set SVM new Level low side + overvoltage detection
00138                                                                                  // this will wait till VCore is below the level
00139   // Set SVS/SVM high side new level
00140   SVSMHCTL = SVSHE + SVSHRVL0 * level + SVMHE + SVSMHRRL0 * level;
00141   while ((PMMIFG & SVSMLDLYIFG) == 0);      // Wait till SVM is settled (Delay)
00142   PMMCTL0 = 0xA500 | (level * PMMCOREV0);   // Set VCore to requested level
00143   while (PMMIFG & SVMLIFG)
00144     PMMIFG &= ~(SVMLIFG);                   // Wait till SVM will not be set anymore
00145   // Set SVS/SVM low side to new level
00146 //  SVSMLCTL = SVSLE + SVSLRVL0 * level + SVMLE + SVSMLRRL0 * level;
00147   PMMCTL0_H = 0x00;                         // Lock PMM module registers for write access
00148 }

Generated on Fri Dec 17 2010 12:08:30 for Multi-cell Lithium-Ion Battery Manager System using MSP430 and BQ76PL536 by  doxygen 1.7.1