I saw that GCB had support for the new PIC16F1788 so I decided to test it on my CHIPINO module. Everything seemed to work fine except ADC.
It would report a constant zero no matter what the voltage was on the ADC pin.
So I pulled up the data sheet and saw the 16F1788 added a Differential Channel Selection feature allowing the negative reference to come from a pin other than -Vref.
This added a setup to the ADCON2 register and unfortunately defaults to the AN0 pin instead of defaulting to the ADNREF setting.
So I added one line to the top of my program to set the ADCON2 to the ADNREF setting.
ADCON2 = 15
Fortunately this worked perfect and the ADC is working again.
Maybe Hugh or Evan can fix this in a future update.
Until then, this simple one line patch seems to fix the issue.
Here is the simple code example I tested using the PICkit 2 USART Terminal window for communication.
'This program reads the potentiometer on AN0 and Serially sends results to PICkit 2
'USART terminal. Using the CHIPINO module with 16 MHz Crystal.
'Chip Settings
#chip 16F1788,16
'Serial settings
#define SerInPort PORTB.6
#define SerOutPort PORTB.7
#define SendAHigh Set SerOutPort off
#define SendALow Set SerOutPort on
#define RecAHigh SerInPort off
#define RecALow SerInPort on
'Set pin directions
Dir SerOutPort Out
Dir SerInPort In
InitSer 1, r9600, 1+WaitForStart, 8, 1, none, invert
ADCON2 = 15 ' Set Negative Reference Setting to ADNREF in ADCON1
Start:
SerPrint 1, "AN0 Reading: "
SerPrint 1, ReadAD(AN0)
SerSend 1, 13
SerSend 1, 10
goto Start
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I saw that GCB had support for the new PIC16F1788 so I decided to test it on my CHIPINO module. Everything seemed to work fine except ADC.
It would report a constant zero no matter what the voltage was on the ADC pin.
So I pulled up the data sheet and saw the 16F1788 added a Differential Channel Selection feature allowing the negative reference to come from a pin other than -Vref.
This added a setup to the ADCON2 register and unfortunately defaults to the AN0 pin instead of defaulting to the ADNREF setting.
So I added one line to the top of my program to set the ADCON2 to the ADNREF setting.
Fortunately this worked perfect and the ADC is working again.
Maybe Hugh or Evan can fix this in a future update.
Until then, this simple one line patch seems to fix the issue.
Here is the simple code example I tested using the PICkit 2 USART Terminal window for communication.
Good work, added to the list. :-)