Hi to All,
this is the my piece of code but in this suppose am giving 0.334v as input to the channel but am not getting equavalent count for this voltage. Can you help anybody please.
/*=============================================================================
= FUNCTION_NAME: =
= adc_initialisation() =
= =
= Design Description: This function Initialises the adc Peripheral =
= Inut Parameters : None =
= Return Type: None =
= =
=============================================================================*/
void adc_initialisation(const UCHAR channel_name, const UCHAR channel_en)
{
SD16CTL|= SD16REFON|SD16SSEL_1; // Reference on 1.2V and SMCLK src
SD16INCTL0|= channel_name; // Channel 0
SD16CCTL0|= SD16UNI|SD16IE; // The Int enable
// SD16INCTL0|= SD16INTDLY_0;
SD16AE|= channel_en; // The 0 channel Enable
}
/*=============================================================================
= FUNCTION_NAME: =
= adc_conversion() =
= =
= Design Description: This function Converts the I/P adc data =
= Inut Parameters : UINT =
= Return Type: None =
= =
=============================================================================*/
UINT adc_conversion(const UCHAR count)
{
UCHAR cnt = 0;
flags.flag0 = CLR; // Clear the Flag initially
while(cnt<count)
{
SD16CCTL0|= SC; // Start the Conversion
while(CLR == flags.flag0); // Check for i.nterrupt genewrated
flags.flag0 = CLR; // Clear the flag
cnt++; // Increment the count
}
return (0); // Send the Average Value
}
/*=============================================================================
= FUNCTION_NAME: =
= adc_interrupt() =
= =
= Design Description: This is the interrupt routine it will give the =
= service to the ADC Peripheral =
= Inut Parameters : NONE =
= Return Type: None =
= =
=============================================================================*/
#pragma vector = SD16_VECTOR
__interrupt void adc_isr (void)
{
__disable_interrupt(); // Disable the interrupt
flags.flag0 = SET; // Set the flg0
myBuffer[i++]= SD16MEM0; // Read the ADC Data Register
__enable_interrupt(); // Disable Interrupt
}