BCL 00000052

MP TypeADC
OS TypeMulti-Task AUTOSAR , etc
Calculation accuracyinteger calculation
Characteristic Conversionlinear conversion
Filter Weighted Moving Average ( WMA )
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.00000052

// Interger constant
#define iInt_const              256U                    // Interger constant

// Filter definitions
#define iWMA_num                4U                      // Weighted moving average number

// MPU definitions
#define iADC_bit                16U                     // MPU ADC bit
                                                         // CAUTION : When Mbed is selected, 16 bit is fixed
#define iPIN_adc                A0                      // MPU Port Pin (ADC)

// P-CMP ( Sysyem Parts , Circuit , IC ) definitions
// Model type System Parts definitions
#define iX_offset               0                       // X offset [mV]
#define iY_offset               0                       // Y offset [unit]
#define iK_gain                 ( 1*iInt_const )        // Gain [mV/unit]

// Circuit definitions
#define iADC_vdd                5000U                   // MPU Vdd [mV]
#define iK_tc                   ( 1*iInt_const )        // Circuit Transformation ratio


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

static sint32 sp( uint16 vi )
{
         sint32 wk = 0;
        
         // Voltage value to Physical value conversion
         wk = ( (sint32)vi – iX_offset ) * iInt_const;
         wk = mac_rnd( wk , iK_gain ) + iY_offset;
        
         // Physical value Weighted Moving Average calculation
         wk = lib_s32_WMA( wk , &Phy_WMA );
        
         return( wk );
}

void cpw( void )
{
         VI_ECU = cp( AI );
}

static uint16 cp( uint16 ai )
{
         // A/D value to Voltage value conversion
         uint16 wk = (uint16)mac_UpLmt( (uint32)ai * iK_tc / iInt_const , iUint16_Max );
         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