AnsweredAssumed Answered

Bug in ADC1_GetConversionValue() ?

Question asked by de_craemer.klaas on Feb 20, 2012
Latest reply on Jul 21, 2012 by zhang.junhe
I was trying to get the ADC working on an STM8S discovery, but left and right alignment setting of the ADC gives different results.

In the file stm8s_adc1.c of the standard firmware library there is:

/* Left alignment */
    {
        /* Read MSB firts*/
        temph = ADC1->DRH;
        /* Then read LSB */
        templ = ADC1->DRL;

        temph = (u16)((u16)(templ << (u8)6) | (u16)(temph << (u8)8));
}


I suppose that last line should be

temph = (u16)((u16)(templ >> (u8)6) | (u16)(temph << (u8)8));

(shifting the lower byte in the other direction)
Right?

Outcomes