News:

Let's find out together what makes a PIC Tick!

Main Menu

adc warning in proteus

Started by Pepe, Jul 23, 2021, 02:36 PM

Previous topic - Next topic

Pepe

why proteus give warning if I don´t use adc channel 7

Device = 18F2550
Declare Xtal = 48
Optimiser_Level = 3
Declare Bootloader off
Declare Create_Coff  On
 
Declare Adin_Res = 10     
Declare Adin_Tad = FRC   
Declare Adin_Stime = 50


Dim CANAL1 As Word
Dim CANAL2 As Word

ADCON2bits_ADFM = 1
ADCON1 = 0xA


TRISA=%11111111
TRISB=%11111111

Do

CANAL1 = ADIn 3
DelayUS 10

CANAL2 = ADIn 4
DelayUS 10

Loop


;-------------------------------------------------------------------------------
;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings

Config_Start
  PLLDIV = 5   ;Divide by 5 (20 MHz oscillator input)
  CPUDIV = OSC1_PLL2   ;[Primary Oscillator Src: /1][96 MHz PLL Src: /2]
  USBDIV = 2   ;USB clock source comes from the 96 MHz PLL divided by 2
  FOSC = HSPLL_HS   ;HS oscillator, PLL enabled (HSPLL)
  FCMEN = OFF   ;Fail-Safe Clock Monitor disabled
  IESO = OFF   ;Oscillator Switchover mode disabled
  PWRT = On       ;PWRT enabled
  BOR = OFF     ;Brown-out Reset disabled in hardware and software
  BORV = 3       ;Minimum setting 2.05V
  VREGEN = OFF   ;USB voltage regulator enabled
  WDT = OFF     ;WDT enabled (control is placed on the SWDTEN bit)
  WDTPS = 256     ;1:32768
  CCP2MX = On   ;CCP2 input/output is not multiplexed with RB3
  PBADEN = OFF   ;PORTB<4:0> pins are configured as digital I/O on Reset
  LPT1OSC = OFF ;Timer1 configured for higher power operation
  MCLRE = OFF   ;MCLR pin enabled; RE3 input pin disabled
  STVREN = OFF   ;Stack full/underflow will not cause Reset
  LVP = OFF       ;Single-Supply ICSP disabled
  XINST = OFF   ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
  Debug = OFF   ;Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
  Cp0 = On   ;Block 0 (000800-001FFFh) is not code-protected
  CP1 = On   ;Block 1 (002000-003FFFh) is not code-protected
  CP2 = On   ;Block 2 (004000-005FFFh) is not code-protected
  CP3 = On   ;Block 3 (006000-007FFFh) is not code-protected
  CPB = On   ;Boot block (000000-0007FFh) is not code-protected
  CPD = OFF   ;Data EEPROM is not code-protected
  WRT0 = On    ;Block 0 (000800-001FFFh) is not write-protected
  WRT1 = On    ;Block 1 (002000-003FFFh) is not write-protected
  WRT2 = On    ;Block 2 (004000-005FFFh) is not write-protected
  WRT3 = On    ;Block 3 (006000-007FFFh) is not write-protected
  WRTC = On    ;Configuration registers (300000-3000FFh) are not write-protected
  WRTB = On    ;Boot block (000000-0007FFh) is not write-protected
  WRTD = OFF   ;Data EEPROM is not write-protected
  EBTR0 = OFF   ;Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks
  EBTR1 = OFF   ;Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks
  EBTR2 = OFF   ;Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks
  EBTR3 = OFF   ;Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks
  EBTRB = OFF   ;Boot block (000000-0007FFh) is not protected from table reads executed in other blocks
Config_End

;**** End of Fuse Configurator Settings ****
;-------------------------------------------------------------------------------       

See_Mos

AN7 is PORTE.2 but 18F2550 only has PORTE.3 which is MCLRE
AN5 PORTE.0 is also missing from the 2550

Pepe

#2
I already know that but if I am not using the An7 why proteus refers to it, I think that is an simulalion error of proteus.

See_Mos

Sorry, I did not read your post as I should have.  I just looked at the errors picture.

I will look again later today

See_Mos

OK, I think this is one for Les to have a look at.

Using ISIS, when the error happens ADCON0 is being set to %00011101 which is channel select for CH7

Comment out either CANAL1 = ADIn 3 or CANAL2 = ADIn 4 and ADCON0 is set correctly, it is only when both are enabled that the error happens. I also tried reversing the sequence but got the same error.

See_Mos

This solved it I think

Do
ADCON0 = 0
CANAL1 = ADIn 3
DelayUS 10
ADCON0 = 0
CANAL2 = ADIn 4
DelayUS 10
Loop

Pepe

thanks See_Mos for your time in solving my question

top204

#7
This is not something the compiler can do, because each PIC device family has different timings for the ADC and different specs for them.

Also, the Isis simulator takes information about the device from the datasheet, which does not imitate the "real" word, and they get it incorrect a lot of times.

Never, never trust a simulation 100%! Always run tests in the "real" world, then if you see issues, take a look at timings around a peripheral and the device's datasheet.

For peripheral testing, I do not use Isis much because they, generally, do not work as they do in the real world, so they cannot be trusted. I use Isis for testing mnemonic placements for arithmetic and logic sequences, and a little for the simpler peripherals, but I've even noticed in Isis that some of the timers do not always actually work correctly sometimes.

All, possible, peripheral anomalies that are seen in a simulation only, I tend to ignore because they cannot be trusted to actually be an anomaly, so it wastes hours of my time looking for something that is not there! In the Isis simulator, it now seems to be quantity of items instead of quality of items, as it used to be. :-( But that, unfortunately, seems to be the standard thing now.