BCL 00000033

MP TypeADC
OS TypeMulti-Task AUTOSAR , etc
Calculation accuracyfloating-point calculation
Characteristic Conversionlinear conversion
Filter Non
Diagnostics Non

Software Specifications

Caution)

Please note that the return value of the Mbed read_u16 function may be MSB-padded or LSB-packed. The adc_read_u16_wrapper function assumes LSB packing.

File

main.c application source code file
pcmp.cADC Component source code file
pcmp.hADC Component header file
oss-ec.h OSS-EC header file

Source Code

  • Constants for components   Constants to match the component
  • Constants for MPU       Constants to match the microcontroller of the product
  • Constants for circuits      Constants to match the circuit of the product

// BCL No.00000033

// MPU definitions
#define iADC_bit                12U                     // MPU ADC bit 8/10/12
#define iADC_group              1U                      // ADC group
#define iADC_GrChNum            8U                      // Number channel in ADC group
#define iPIN_pos                7U                      // Sensor position in ADC group

// P-CMP ( Sysyem Parts , Circuit , IC ) definitions
// Model type System Parts definitions
#define iX_offset               0.0F                    // X offset [V]
#define iY_offset               0.0F                    // Y offset [unit]
#define iK_gain                 1.0F                    // Gain [V/unit]

// Circuit definitions
#define iADC_vdd                5.0F                    // MPU Vdd [V]
#define iK_tc                   1.0F                    // Circuit Transformation ratio


void spw( void )
{
         PHY = sp( VI );
}

static float32 sp( float32 vi )
{
         // Voltage value to Physical value conversion
         float32 wk = ( vi – iX_offset ) / iK_gain + iY_offset;
        
         return( wk );
}

void cpw( void )
{
         VI_ECU = cp( AI );              // A/D value to Voltage value conversion
}

static float32 cp( uint16 ai )
{
         // A/D value to Voltage value conversion
         float32 wk = (float32)ai * iADC_vdd / ( 1<<iADC_bit ) * iK_tc;
        
         return( wk );
}

void mpw( void )
{
         AI = mp();
}

static uint16 mp( void )
{
         uint16 wk;
        
         // Read A/D convension value
         uint8 sts = adc_read_u16_wrapper( an , &wk );
        
         return( wk );
}


OSS-EC Site