2010-04-16 01:01 PM
AWD problems
2011-05-17 06:08 AM
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.