Ok I think I now understand the settings for ANSEL. Reading the datasheet again
So if I wanted all analogue I set ANSEL to 11111111 - all digital 00000000ANSEL — ANALOG SELECT REGISTER (ADRESS: 91h) (PIC16F676 ONLY)
ANS7 ANS6 ANS5 ANS4 ANS3 ANS2 ANS1 ANS0
bit 7 bit 0
bit 7-0: ANS<7:0>: Analog Select between analog or digital function on pins AN<7:0>, respectively.
1 = Analog input. Pin is assigned as analog input.(1)
0 = Digital I/O. Pin is assigned to port or special function.
Ergo to set AN0, AN1, AN2 and AN4 Ansel should = 00010111, which is exactly what Darrel suggested. However when compiled with this setting the 4th output still runs at full speed with no control.
Could it be that the issue is with the declaration of the array - as it has [3] and I would assume that there are 4 channels so maybe this should be [4] ??
Looked like that was teh cause - I now have 4 working channels... just need to resolve the issue of the PIC locking on at full throttle and I'm done !
Bookmarks