In reference to this thread http://www.picbasic.co.uk/forum/showthread.php?t=12714 I still can't get the A/D conversion working when porting the code from 16F877A to an 18F4550.
For some reason the following code work on the 16F877A but not the 18F4550
Code:
DEFINE ADC_BITS 10 ' Set-up ADC for fastest 10-bit results
DEFINE ADC_CLOCK 2
DEFINE ADC_SAMPLEUS 5
INCLUDE "DT_Analog.pbp"
MaxSetPoint CON 350 ' Pot fully clockwise
MinSetPoint CON 100 ' Pot fully counter clockwise
ADbits = 14 ' set A/D resolution to 14-bits
CMCON = 7 ' disable Comparators
ADCON1 = %10000010 ' AN0-4 Analog, Right justify
ADCON1 = $0F
I've checked the datasheet and read a section on A/D from one of my PbP project books, and if I've read it correctly the ADCON1 = %10000010 should set the register up as output right justified (bit 7 set to 1), AN7-AN5 digital, AN4-AN0 analogue, Vref+=vdd and Vref-=Vss.
However it then has the line ADCON1 = $0F which (from googling) sets all pins to digital... OK fair enough I though, simply comment out this line, however when I do this all I get on the LCD display is a row of squares on the top row, which flash as the PIC is performing the rest of the functions (PID calculations etc). If I then uncomment the ADCON1=$0F line the temperatures from all the probes (which are on port D) are displayed. It is as if ADCON1 is setting all pins on all ports to digital
Bookmarks