News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

18f4620 problems !

Started by vs2prod, Mar 10, 2021, 07:05 PM

Previous topic - Next topic

vs2prod

Hello,

i have a problem: my program run correctly with a 18F4550 but not with a 18f4620 (it is the same pin out) . i see on the web some problems with this PIC and proton basic.
i simulate on proteus and it run perfectly. i change the config fuses no success..

anybody have un idea ?

RGV250

Hi,
Proteus does not do a very good job where fuses are concerned, in my experience anyway.
Have you used JB's Fuse configurator to set the fuses in the 4620?, probably best to try a blinking LED and then copy your code after you know the fuses are correct with the LED.
Also without posting any code it could be a peripheral that is set differently.

Regards,
Bob

top204

Bob is correct.

The 18F4550 device and the 18F4620 device are entirely different, so there are a lot of differences in their peripheral setups using the SFRs and bits of the SFRs etc... Don't let the fact that they are both 18F devices fool you into thinking they are the same internally, as I can assure you they are not, which is something I have had to battle with within the compiler's code for many years now. :-)

Without seeing code it is impossible to give an answer.

vs2prod

hello,

i have made a simple program test: the problem comes from RE0 and RE1,  i cant change these outputs.RE2 is output OK

Acdon1 is set ok ( no analog input allowed) and TRISE is %00000000 (re0,re1,re2 as outputs)
i try also to put pulls up no change 

my test:

Device = 18F4620
Declare Xtal = 20
Config_Start
   
   OSC = HS            ' HS oscillator
   FCMEN = OFF          ' *Fail-Safe Clock Monitor disabled
   IESO = Off           ' *Oscillator Switchover mode enabled
   PWRT = OFF           ' *PWRT enabled
   BORV = 0             ' Maximum setting
   WDT = OFF            ' HW Disabled - SW Controlled
   WDTPS = 1            ' 1:1
   MCLRE = On           ' *MCLR pin enabled; RE3 input pin disabled
   LPT1OSC = OFF        ' *Timer1 configured for higher power operation
   PBADEN = OFF         ' PORTB <4:0> pins are configured as digital I/O on Reset
   CCP2MX = PORTC       ' *CCP2 input/output is multiplexed with RC1
   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 = OFF            ' Block 0 (000800-001FFFh) not code-protected
   CP1 = OFF            ' Block 1 (002000-003FFFh) not code-protected
   CP2 = OFF            ' Block 2 (004000-005FFFh) not code-protected
   CPB = OFF            ' Boot block (000000-0007FFh) not code-protected
   CPD = OFF            ' Data EEPROM not code-protected
   WRT0 = OFF           ' Block 0 (000800-001FFFh) not write-protected
   WRT1 = OFF           ' Block 1 (002000-003FFFh) not write-protected
   WRT2 = OFF           ' Block 2 (004000-005FFFh) not write-protected
   WRTB = OFF           ' Boot block (000000-0007FFh) not write-protected
   WRTC = OFF           ' Configuration registers (300000-3000FFh) not write-protected
   WRTD = OFF           ' Data EEPROM not write-protected
   EBTR0 = OFF ' Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
   EBTR1 = OFF ' Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
   EBTR2 = OFF ' Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
   EBTRB = OFF ' Boot block (000000-0007FFh) not protected from table reads executed in other blocks
Config_End

ADCON1.0 = 1   
ADCON1.1 = 1     
ADCON1.2 = 1   
ADCON1.3 = 1   
ADCON1.4 = 0    ' voltage référence 0V
ADCON1.5 = 0    ' voltage Référence 5V
ADCON1.6 = 0    ' NA
ADCON1.7 = 0    ' NA

TRISE = %00000000     ; Port E output ()


bou:

PORTE.0 = 1
PORTE.1 = 1
PORTE.2 = 1
DelayMS 100

PORTE.0 = 0
PORTE.1 = 0
PORTE.2 = 0
DelayMS 100

GoTo bou

Gamboa

#4
Vs2prod,

Try
LATE.0 = 1 instead of PORTE.0 = 1 and LATE.0 = 0 instead of PORTE.0 = 0

Regards,
Gamboa
Long live for you

vs2prod

thanks Gamboa.

i try it . nothing new

regards

Craig

#6
Hi
I used this basic setup on a project and works fine with the 18F4620.


Device = 18F4620
 
;-------------------------------------------------------------------------------
Config_Start
  OSC = HS   ;HS oscillator
  FCMEN = OFF   ;Fail-Safe Clock Monitor disabled
  IESO = OFF   ;Oscillator Switchover mode disabled
  PWRT = OFF   ;PWRT disabled
  BOREN = SBORDIS   ;Brown-out Reset enabled in hardware only (SBOREN is disabled)
  BORV = 3   ;Minimum setting
  WDT = OFF   ;WDT disabled (control is placed on the SWDTEN bit)
  WDTPS = 32768   ;1:32768
  CCP2MX = PORTC   ;CCP2 input/output is multiplexed with RC1
  PBADEN = OFF    ;PORTB<4:0> pins are configured as Digital input channels on Reset         
  LPT1OSC = OFF   ;Timer1 configured for higher power operation
  MCLRE = On   ;MCLR pin enabled; RE3 input pin disabled
  STVREN = On   ;Stack full/underflow will 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 = OFF   ;Block 0 (000800-003FFFh) not code-protected
  CP1 = OFF   ;Block 1 (004000-007FFFh) not code-protected
  CP2 = OFF   ;Block 2 (008000-00BFFFh) not code-protected
  CP3 = OFF   ;Block 3 (00C000-00FFFFh) not code-protected
  CPB = OFF   ;Boot block (000000-0007FFh) not code-protected
  CPD = OFF   ;Data EEPROM not code-protected
  WRT0 = OFF   ;Block 0 (000800-003FFFh) not write-protected
  WRT1 = OFF   ;Block 1 (004000-007FFFh) not write-protected
  WRT2 = OFF   ;Block 2 (008000-00BFFFh) not write-protected
  WRT3 = OFF   ;Block 3 (00C000-00FFFFh) not write-protected
  WRTC = OFF   ;Configuration registers (300000-3000FFh) not write-protected
  WRTB = OFF   ;Boot Block (000000-0007FFh) not write-protected
  WRTD = OFF   ;Data EEPROM not write-protected
  EBTR0 = OFF   ;Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
  EBTR1 = OFF   ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
  EBTR2 = OFF   ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
  EBTR3 = OFF   ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
  EBTRB = OFF   ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
Config_End

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

Declare Xtal 20                                                 
'-----------------------------------------------------------'
' Calculated Baudrate = 116279 @ Xtal 20MHz, Error = 0.94%  '   
' ----------------------------------------------------------'
 RCSTA     = 144 ; Enable continuous receive             '
 TXSTA     = 36  ; Enable transmit, BRGH = 1             '
 SPBRG     = 42  ; Baud Rate Generator Low Byte Value    '
 SPBRGH    = 0   ; Baud Rate Generator High Byte Value   '
 BAUDCON.3 = 1   ; Enable the 16 bit Baud Rate Generator '
'-----------------------------------------------------------'
   
'----------------------------------------------------------------------------------------
' Set up the PORT Pins
'----------------------------------------------------------------------------------------
 PORTA = 0                                  ' PORTA Outputs Set To LOW
 PORTB = 0                                  ' PORTB Outputs Set To Low
 PORTC = 0                                  ' PORTC Outputs Set To Low
 PORTD = 0                                  ' PORTD Outputs Set To Low
 PORTE = 0                                  ' PORTE Outputs Set To Low
 
 TRISA = %00111011                          ' PORTA 2,6-7 Outputs, 0,1,3,4,5 Inputs
 TRISB = %00110000                          ' PORTB 0-3,6,7 Outputs, 4&5 Inputs
 TRISC = %00100001                          ' PORTC 1-4,6-7 Outputs, 0,5 Inputs
 TRISD = %00001000                          ' PORTD 0-2,4-7 Outputs, 3 Inputs
 TRISE = %1000                              ' PORTE 0-2 Outputs, 3 Input "MCLR"
'---------------------------------------------------------------------------------------
' Set up the Declares
'---------------------------------------------------------------------------------------           
 Declare PORTB_Pullups OFF                   ' Switch PORTB'S Internal Pullup Resistors OFF
 Declare Dead_Code_Remove=On                     
 Declare Warnings=off
 Declare Reminders=off
 Declare All_Digital = True                  'CMCON = 7 ' Set Port Pins To Digital Instead of using " ALL_DIGITAL = TRUE "
   
 Declare Shift_DelayUs = 1                   ' SHIN / SHOUT Declare Setup
 Declare Hserial_Baud = 9600                 ' Set baud rate to 9600_RS232
 Declare Hserial_RCSTA = %10010000           ' Enable serial port and continuous receive RS232
 Declare Hserial_TXSTA = %00100100           ' Enable transmit and asynchronous mode     RS232
 Declare Hserial_Clear = On                  ' Enable Error clearing on received characters  RS232
 Declare serial_data   = 8                   ' Setup For RS232 Output To PC - TESTING Purposes
 
 Declare LCD_DTPin PORTB.0                   ' Used for 4-line interface DB0-DB3
 Declare LCD_ENPin PORTD.5                   ' PORTD.2 Alpha LCD E enable Pin
 Declare LCD_RSPin PORTD.6                   ' PORTD.4 Alpha LCD RS Register select Pin
 Declare LCD_Interface 4                     ' 4 Line LCD Interface
 Declare LCD_Lines 2                         ' 2 x 16 Line Alpha LCD Display
 Declare LCD_Type 0                          ' 0 Selects that the LCD is type: "ALPHA"
 
 Declare CCP2_Pin PORTC.1                    ' Declare HWPM on Portc.1 CCP2 Channel_2 For BACKLIGHTING
 Declare CCP1_Pin PORTC.2                    ' Declare HWPM on Portc.2 CCP1 Channel_1 For BUZZER
 Declare Bootloader = On
 
 '   Declare Hbus_Bitrate 400             ' RTC
 '   Declare Float_Display_Type = Fast    ' RTC
 '   Declare serial_data 8                ' RTC Set Serin & Serout data Bits to 8 
'-------------------------------------------------------------------------------   
' Set A/D Convertor     "" DON'T USE ADCON2 = %00000000 ""
'-------------------------------------------------------------------------------
 LATA.4 = 1                           ' Used To Stop RA4 From Self Triggering On & OFF
 LATA.5 = 1                           ' Used To Stop RA5 From Self Triggering On & OFF
 T0CON  = %00000000                   ' IF Things Start "MESSING" Around Remove T0CON
 ADCON1 = %00001011                   ' %00001011 Analogue AN0 - AN3, Digital AN4 - AN12   
 ADCON2.7 = 1                         ' Right Justified
 Declare Adin_Stime = 50              ' Sample time of A/D Convertor 50 ms
 Declare Adin_Res = 10                ' 10-bit result required
 Declare Adin_Tad = FRC               ' RC oscillator chosen

Regards
Craig
 

John Drew

Vs2prod, I've used the 18f4620 many times with the compiler and it has proven very reliable in real hardware, never a problem.
John