Pic18F452


Closed Thread
Results 1 to 23 of 23

Thread: Pic18F452

Hybrid View

  1. #1
    Join Date
    Dec 2005
    Posts
    11

    Default Pic18F452

    Hi iam am trying to use a lcd display using the picbasic pro software the display is working fine using the defult pin setup but when i change the pin configeration using the DEFINES i cant get the display to work.
    can anyone help me out thanks.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    That's the equivallent of...

    Question : "My car's broke - can you fix it?"

    Answer : "Sure, bring it in and we'll take a look".

    Inotherwords, post your Defines so we can see them, along with your chip register initialisation... ie if you're using analogue pins your ADCON or CMCON setup, and confirm that if you're using odd hardware pins like PortA.4, you've got a pull-up on it.

  3. #3
    Join Date
    Dec 2005
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Hi Melanie my lcd defines are:
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTE
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTE
    DEFINE LCD_EBIT 1
    DEFINE LCD_RWREG PORTE
    DEFINE LCD_RWBIT 2

  4. #4
    MikeTamu's Avatar
    MikeTamu Guest


    Did you find this post helpful? Yes | No

    Default

    If you look at the datasheet, you can see that PortE, bit 0,1, and 2 are all Analog ports. So what is most likely happening, is that the PIC is in analog mode for these pins and not giving you digital outputs.

    Put this in your code before the DEFINES:

    ADCON1.3=0
    ADCON1.2=1
    ADCON1.1=1
    ADCON1.0=0

    These 4 lines will make all of your analog pins into digital pins. If you need to use some of your digital pins as analog ones, then just change these 4 bits according to the table in the datasheet referenced below.

    To see how I came to this, look at page 182 (184 of pdf) in the PIC 18f452 datasheet.

  5. #5
    Join Date
    Dec 2005
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Thank you very much MikeTamu i just assumed that PBP took care of all that for me as there is no reference to it in the pbp manual.

    Thanks again.

  6. #6
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Please Help !

    I am having similar problems trying to get an LCD working on EasyPIC3 from Mikroelectronika Board using PBP and 18F452 MCU. Although i can get the LED to blink , I cannot get the LCD to work. Can you help.

    EasyPIC3 Development Board Configuration -
    D4 - RB4
    D5 - RB5
    D6 - RB6
    D7 - RB7
    RS - RB2
    E - RB3
    RW - GND

    My Code:

    DEFINE OSC 8

    ' HARDWARE DEFINES
    '-----------------------------------------------------------------
    ' Define LCD pins

    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 2
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3

    '-----------------------------------------------------------------
    TRISA = %111111 'INITIALIZE PORT DIRECTIONS
    TRISB = %00000000
    TRISC = %10101001
    TRISD = %00000011
    TRISE = %00000111
    Adcon1 = 7 ' Set PORTA DIGITAL
    INTCON2.7=1 ' DISABLE Pull-Up's
    '-----------------------------------------------------------------
    PAUSE 500

    Lcdout $fe , 1 , "EasyPIC3 DEV"
    LCDOut $FE,$C0, "Board v1A"
    PAUSE 2000

    END

  7. #7
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by MikeTamu View Post
    If you look at the datasheet, you can see that PortE, bit 0,1, and 2 are all Analog ports. So what is most likely happening, is that the PIC is in analog mode for these pins and not giving you digital outputs.

    Put this in your code before the DEFINES:

    ADCON1.3=0
    ADCON1.2=1
    ADCON1.1=1
    ADCON1.0=0

    These 4 lines will make all of your analog pins into digital pins. If you need to use some of your digital pins as analog ones, then just change these 4 bits according to the table in the datasheet referenced below.

    To see how I came to this, look at page 182 (184 of pdf) in the PIC 18f452 datasheet.
    Thanks for the clear explanation !
    As you said this will turn all 8 pins into digital.
    Would it be possible to get AN0 and AN1 digital and all the others (AN2 to AN7) analog ?
    It's still unclear in this case what's ADCON0 for !
    Thanks for clearing me out.
    Lotondo

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Hava a look in the datasheet, register 17-2, PDF page 184

    <img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1361&stc=1&d=117069960 6">
    Attached Images Attached Images  
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. PIC18f452 blinking led ?
    By iugmoh in forum General
    Replies: 5
    Last Post: - 7th March 2008, 14:12
  2. Serial communication with pic18f452
    By tamersoss in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th December 2007, 21:27
  3. communicating pic18f452 with pic16f877a
    By tamersoss in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th July 2007, 19:54
  4. Dealy in turn ON of PIC18F452
    By genesis in forum General
    Replies: 1
    Last Post: - 13th October 2006, 10:40
  5. Replies: 5
    Last Post: - 26th March 2006, 19:26

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts