Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Migration from PIC16F877A to PIC18F4620

Status
Not open for further replies.
Joined
Apr 8, 2012
Messages
201
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Activity points
0
My Circuit Consisting of PIC16F877A was changed to PIC18F4620 and the mikroBasic code which worked well for PIC16F877A seems having problem with PIC18F4620. The LCD is not displaying anything in the 8-bit mode, but works well with 4-bit data mode. Can anyone tell me what might be the problem?
 

hi

can you post the diagrams and codes that you use for both the controllers?
it will help to solve easily

ml
 

Which port do you use for PIC18?
Since 4bit mode can working but not 8bit mode, maybe you use the VUSB pin on PIC18 that can't be digital output.
 

hi

can you post the diagrams and codes that you use for both the controllers?
it will help to solve easily

ml

I have attached the files.
 

Attachments

  • files.rar
    26.9 KB · Views: 74
  • pic16f877a.bmp
    880.9 KB · Views: 84
  • pic18f4620.bmp
    978.8 KB · Views: 76
  • pic16f877a.txt
    1.4 KB · Views: 51
  • pic18f4620.txt
    2 KB · Views: 72

Which port do you use for PIC18?
Since 4bit mode can working but not 8bit mode, maybe you use the VUSB pin on PIC18 that can't be digital output.

I am using PORTC for 8-bit data and PORTE for ctrl

PIC18F4620 PORT LCD
RC0 D0
RC1 D1
RC2 D2
RC3 D3
RC4 D4
RC5 D5
RC6 D6
RC7 D7

RE0 RS
RE1 RW
RE2 E

---------- Post added at 07:45 ---------- Previous post was at 07:32 ----------



---------- Post added at 07:46 ---------- Previous post was at 07:45 ----------

Which port do you use for PIC18?
Since 4bit mode can working but not 8bit mode, maybe you use the VUSB pin on PIC18 that can't be digital output.

I changed the ctrl port from E0, E1, E2 to D1, D2, D3 and I am getting the 1st and 3rd line display in my 20X4 LCD. The 2nd and 4th line is not displaying.
 

My Circuit Consisting of PIC16F877A was changed to PIC18F4620 and the mikroBasic code which worked well for PIC16F877A seems having problem with PIC18F4620. The LCD is not displaying anything in the 8-bit mode, but works well with 4-bit data mode. Can anyone tell me what might be the problem?

A common issue when coding for the PIC18F series is proper configuration of the system clock and specifying the correct system clock frequency in the Compiler IDE.

Many of the routines in the MikroE library require that the correct system clock frequency be specified in the IDE.

Any routine requiring the use of delays, like the LCD routines, require the correct system clock frequency to properly generate these delays.

The PIC18F series utilize a PLL which can generate a much higher system clock frequency than expected.

What are the PIC's current Oscillator and Configuration Register Settings?

Have you enter the correct system clock frequency in Mikro IDE Project Settings?

BigDog

---------- Post added at 03:45 ---------- Previous post was at 03:18 ----------

Glancing at your code, another possible issue is the use of both the 8-bit and 4-bit LCD routines:

Code:
'Microcontroller:           PIC18F4620
'Clock Frequency:           8MHz

main:
     ADCON0 = 7
     ADCON1 = 7              ' All pins digital.
     CMCON = 7               ' All comparator Off.
     TRISB = %00011111
     TRISC = %00000000
     TRISD = %00000000
     TRISE = %1000
     PORTB = 0
     PORTC = 0
     PORTD = 0

     PORTE.0 = 0
     PORTE.1 = 0
     PORTE.2 = 0
     PORTE.3 = 1

     Lcd8_Config(PORTE, PORTC, 2,1,0, 7,6,5,4,3,2,1,0)        [COLOR="#FF0000"]//8-bit LCD Routines and Configuration[/COLOR]
     Lcd8_Cmd(LCD_TURN_ON)
     Lcd8_Cmd(LCD_CURSOR_OFF)
     Lcd8_Cmd(LCD_CLEAR)
     Lcd8_Out(1,1, "PIC18F4620 Based")
     Lcd8_Out(2,1, "XXXXXXXXXXXXXXXXXXXX")
     Lcd8_Out(3,1, "XXXXXXXXXXXXXXXXXXXX")
     Lcd8_Out(4,1, "XXXXXXXXXXXXXXXXXXXX")
     

     while(1)
     

        select case PORTB

           case %00000001
                delay_ms(10)
                if (PORTB = %00000001) and (PORTD = %00000000) then
                   delay_ms(10)
                     if (PORTB = %00000000) and (PORTD = %00000000) then
                        PORTD =  %00000001
                        [COLOR="#FF0000"]Lcd_Cmd[/COLOR](LCD_CLEAR)                                  [COLOR="#FF0000"]//4-bit LCD Routines[/COLOR]
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](1,1, "RELAY ON")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](2,1, "RELAY ON")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](3,1, "RELAY ON")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](4,1, "RELAY ON")
                     end if
                end if

           case %00000010
                delay_ms(10)
                if (PORTB = %00000010) and (PORTD = %00000001) then
                   delay_ms(10)
                     if (PORTB = %00000000) and (PORTD = %00000001) then
                        PORTD =  %00000000
                        [COLOR="#FF0000"]Lcd_Cmd[/COLOR](LCD_CLEAR)                                    [COLOR="#FF0000"]//4-bit LCD Routines[/COLOR]
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](1,1, "RELAY OFF")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](2,1, "RELAY OFF")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](3,1, "RELAY OFF")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](4,1, "RELAY OFF")
                     end if
                end if
                
        end select

    wend

end.


BigDog
 

A common issue when coding for the PIC18F series is proper configuration of the system clock and specifying the correct system clock frequency in the Compiler IDE.

Many of the routines in the MikroE library require that the correct system clock frequency be specified in the IDE.

Any routine requiring the use of delays, like the LCD routines, require the correct system clock frequency to properly generate these delays.

The PIC18F series utilize a PLL which can generate a much higher system clock frequency than expected.

What are the PIC's current Oscillator and Configuration Register Settings?

Have you enter the correct system clock frequency in Mikro IDE Project Settings?

BigDog

---------- Post added at 03:45 ---------- Previous post was at 03:18 ----------

Glancing at your code, another possible issue is the use of both the 8-bit and 4-bit LCD routines:

Code:
'Microcontroller:           PIC18F4620
'Clock Frequency:           8MHz

main:
     ADCON0 = 7
     ADCON1 = 7              ' All pins digital.
     CMCON = 7               ' All comparator Off.
     TRISB = %00011111
     TRISC = %00000000
     TRISD = %00000000
     TRISE = %1000
     PORTB = 0
     PORTC = 0
     PORTD = 0

     PORTE.0 = 0
     PORTE.1 = 0
     PORTE.2 = 0
     PORTE.3 = 1

     Lcd8_Config(PORTE, PORTC, 2,1,0, 7,6,5,4,3,2,1,0)        [COLOR="#FF0000"]//8-bit LCD Routines and Configuration[/COLOR]
     Lcd8_Cmd(LCD_TURN_ON)
     Lcd8_Cmd(LCD_CURSOR_OFF)
     Lcd8_Cmd(LCD_CLEAR)
     Lcd8_Out(1,1, "PIC18F4620 Based")
     Lcd8_Out(2,1, "XXXXXXXXXXXXXXXXXXXX")
     Lcd8_Out(3,1, "XXXXXXXXXXXXXXXXXXXX")
     Lcd8_Out(4,1, "XXXXXXXXXXXXXXXXXXXX")
     

     while(1)
     

        select case PORTB

           case %00000001
                delay_ms(10)
                if (PORTB = %00000001) and (PORTD = %00000000) then
                   delay_ms(10)
                     if (PORTB = %00000000) and (PORTD = %00000000) then
                        PORTD =  %00000001
                        [COLOR="#FF0000"]Lcd_Cmd[/COLOR](LCD_CLEAR)                                  [COLOR="#FF0000"]//4-bit LCD Routines[/COLOR]
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](1,1, "RELAY ON")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](2,1, "RELAY ON")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](3,1, "RELAY ON")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](4,1, "RELAY ON")
                     end if
                end if

           case %00000010
                delay_ms(10)
                if (PORTB = %00000010) and (PORTD = %00000001) then
                   delay_ms(10)
                     if (PORTB = %00000000) and (PORTD = %00000001) then
                        PORTD =  %00000000
                        [COLOR="#FF0000"]Lcd_Cmd[/COLOR](LCD_CLEAR)                                    [COLOR="#FF0000"]//4-bit LCD Routines[/COLOR]
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](1,1, "RELAY OFF")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](2,1, "RELAY OFF")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](3,1, "RELAY OFF")
                        [COLOR="#FF0000"]Lcd_Out[/COLOR](4,1, "RELAY OFF")
                     end if
                end if
                
        end select

    wend

end.


BigDog

OSC freq = 8Mhz and In both the compiler and proteus it is entered corrrctly. What is configuration settings.
 

The Configuration Register Settings configure various features of the PIC including the PLL in the case of PIC18F4620.

You maybe running a system clock with a much higher frequency than 8MHz.

Also why are you mixing the 8-bit and 4-bit LCD libraries as I have indicated in your posted code?

BigDog
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top