cancel
Showing results for 
Search instead for 
Did you mean: 

AWD problems

michal239955_st
Associate
Posted on April 16, 2010 at 22:01

AWD problems

1 REPLY 1
michal239955_st
Associate
Posted on May 17, 2011 at 15:08

I've solved my problem:

If I want to set High Treshold to 900d using ((u16)900); it will set 12d. How is it posible. Well 900d is 0000001110000100b

and the ADC_HTR register is left alignght. The Function ADC1_SetHighTreshhold takes eight MSB (00000011) and writes them to 

ADC_HTRH and two LSB bits (in this case 00) writes to ADC_HTRL, so the end effect is 0000001100b=12d. So if w want to set High Treshold to 900d i have to write ((u160xE100). Watch why. 900d=1110000100b, so 11100001b=0xE1 and 00b=0x00. I Hope it is clear. Unfortunately the Firmware Library doesn't tell anything how data is treated by functions if the function operates on left aligned registers. Luckily i managed to figure out my problem.