⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conversion_v1.1.7.c

📁 MSP430f2013 ADC, LCD drivers using 74168 shift registers
💻 C
字号:
/*=============================================================================
//   File : ADC_V1.1.C                                                       //
//                                                                           //
//   Abstract: This Source file containing the source code for initialisation//
//             of ADC and conversion                                         //
//   Compiler : IAR Embedded Work Bench                                      //
//                                                                           //
//   Author : Kuberappa.M.Sajjan                                             //
//   E-mail : kuber@unifiest.com                                             //
//                                                                           //
//                                                                           //
=============================================================================*/



/*---------------------------- Preprocessor Directives ----------------------*/

#include "datatypes_V1.1.h"        // Contains the Basic Datatypes for  Appl
#include "adc_V1.1.7.h"              // Contains the basic function prototype and
                                     // definition for ADC
#include "lcd_v1.1.h"
#include "conversion_v1.1.7.h"       // Conversion Header File
#include "io430.h"                   // Target Header File

















/*--------------------------- Macros and Constants --------------------------*/


const UCHAR strn[3] = "Kg";





/*--------------------------- Global Variable Declarations ------------------*/

#pragma datasegseg=MY_SEGMENT  
FLOAT offset_LT,offset_RT,m_final;
#pragma dataseg=default 








/*-------------------------- Function Prototypes ----------------------------*/


/*=============================================================================
=     FUNCTION_NAME:                                                          =
=      convert_data()                                                         = 
=                                                                             =
=     Design Description: This function Converts the Ana data into dig data   =
=     Inut Parameters : UINT                                                  =
=     Return Type:      UINT                                                  =
=                                                                             =
=============================================================================*/
 
  
UINT conversion_data(UINT conv_data)
{
  UINT dig_data,mask_data_1,mask_data_2;
  mask_data_1 = 0xFF00&conv_data;           // Mask Lower Byte
  mask_data_1 = mask_data_1>>8;             // Shift the MSB to LSB
  mask_data_1 = ((mask_data_1&0xF0)>>4)*CUBE+(((mask_data_1&0x0F))*SQUARE);// Convert to decimal val
  mask_data_2 = 0x00FF&conv_data;           // Mask the Higher byte
  mask_data_2 = ((mask_data_2&0xF0)>>4)*ONE+(((mask_data_2&0x0F))); // convert to decimal value
  dig_data = mask_data_1 + mask_data_2;     // Add the Higher Byte and Lower Byte
  return dig_data;                          // return the byte 
}

/*=============================================================================
=     FUNCTION_NAME:                                                          =
=      system_offset_adc_conv(UCHAR)                                          = 
=                                                                             =
=     Design Description: This function does the setting the offset and       =
=     Inut Parameters : UCHAR                                                 =
=     Return Type:      NONE                                                  =
=                                                                             =
=============================================================================*/

void system_offset_adc_conv(UCHAR command)
{
  
  UCHAR adc_offset_count = 0;
  switch(command)
  {
    case OFFSET:                           // If the s/m in offset mode
      while(adc_offset_count<=1)           // If the count is less than 1 or eq 2
      {
          switch(adc_offset_count)
          {
              case CLR:           // if the count is Zero den cal for Right side   
              offset_LT = (RESOLUTION*(conversion_data \
                          (adc_conversion_channel0(adc_offset_count,COUNT))));
                          // This will gives offset value for left side of the 
                          // pltform 
              break;
              case SET:   // If the count is One then calculate for Right side
              offset_RT = (RESOLUTION*(conversion_data\
                          (adc_conversion_channel0(adc_offset_count,COUNT))));
                          // This will calculate the offset for the Righr side
                          // Platform
              break;
              default:    // Other wise simply break the Execution
              break;
          }
          adc_offset_count++;  // Increment the count
      }
    break;       
    case READ :                // If the s/m in User mode 
    adc_offset_count = 0;
    while(adc_offset_count<=1) // If the count is eq 1 r less than 
    {
        switch(adc_offset_count)
        {
          case CLR:            // If the count is Zero check for the channel0
          m_final = ((RESOLUTION*(conversion_data \
                    (adc_conversion_channel0(adc_offset_count,COUNT))))\
                    - offset_LT);    // calculate the wt at the Lt side of body
          break;
          case SET:            // If the count is One
          m_final = ((RESOLUTION*(conversion_data \
                    (adc_conversion_channel0\
                    (adc_offset_count,COUNT))))- offset_RT);
                               // Then calculate the wt at RT side of the body   
          break;
          default:                 // otherwise break the execution
          break;
       }
       lcd_display_float_wt((ROW1+adc_offset_count),COL5,m_final);
       lcd_displaydata((ROW1+ adc_offset_count),COL12,strn); // display the Unit
       adc_offset_count++;        // Increment the Count 
    }    
    break;                    
    default:                      // other wise simply break the execution
    break;
  }

}







⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -