PIC18F4620 Troubles


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2007
    Location
    Harvest, Alabama
    Posts
    10

    Default PIC18F4620 Troubles

    I am taking the standard program to demo the PIC16F877A as a clock and starting to branch out leaning as I go. Sorry if I am just leaning but I could really use some help The problem obviously is in configuration of the ports and interrupts.

    Since the PIC18F4620 has several timers rather than the one of the PIC16F877A I assume that some sort of configuration for setting the interrupts on should be done differently but I am not entirely able to get this down. Chalk it up to learning but I need some help on this one.

    I will include my defines and the settings and what should be printing out. The rest of the program really is quite generic.

    Defines --
    Define LCD_DREG PORTD ' Define LCD connections
    Define LCD_DBIT 4
    Define LCD_RSREG PORTE
    Define LCD_RSBIT 0
    Define LCD_EREG PORTE
    Define LCD_EBIT 1
    ADCON1 = 7 ' PORTA and E digital
    Low PORTE.2 ' LCD R/W low = write

    ' Set TMR0 to interrupt every 16.384 milliseconds
    T0CON.7 = 1 ' Set Timer0 on!
    T0Con.6 = 0 ' Set as a 16 bit timer/counter
    T0Con.5 = 0 ' Set the internal clock active
    T0Con.4 = 0 ' Set Source edge bit = low to high on T0CLKI pin
    T0Con.3 = 1 ' Bypass the prescaler (Revisit this one!)
    T0Con.2 = 0 ' Prescaler settings
    T0Con.1 = 0
    T0Con.0 = 0
    TRISD = %11111111

    'PSPCON = 0
    'OPTION_REG = $88 ' Set TMR0 configuration and enable PORTB pullups
    Enable interrupt ' Enable TMR0 interrupts
    'INTCON =
    On Interrupt Goto tickint

    -===

    If you go to the standard clockx example on the melabs site you get the rest of the code, I really don't expect it to be of much interest.


    My issue is that the system has an led that flashes with each interrupt and it appears to be working just fine. The problem is that the LCDOUT writing per this program is not working. It works just fine with the PIC16F877A chip.

    Help Please

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


    Did you find this post helpful? Yes | No

    Default

    Hi and welcome on the forum.

    Try to change ADCON1=7 to ADCON1=$0F.
    Steve

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

  3. #3
    Join Date
    May 2007
    Location
    Harvest, Alabama
    Posts
    10


    Did you find this post helpful? Yes | No

    Smile Please tell why

    First Thanks!

    Next I will try your solution and report the results and report if there are any problems.

    Finally: Please tell me why this should work. In trying to read all the fun stuff down in the chip technical papers I must be missing something and I definitely want to be more astute as to why as well as how.

    Thanks again
    Paul

  4. #4
    ra68gi's Avatar
    ra68gi Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by CluckShot View Post
    Defines --
    Define LCD_DREG PORTD ' Define LCD connections
    Define LCD_DBIT 4
    Define LCD_RSREG PORTE
    Define LCD_RSBIT 0
    Define LCD_EREG PORTE
    Define LCD_EBIT 1
    ADCON1 = 7 ' PORTA and E digital
    Low PORTE.2 ' LCD R/W low = write


    Help Please
    Try adding "Define LCD_BITS 4 " to your defines.

    Regards
    Raghunathan.

  5. #5
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Post search engine

    Quote Originally Posted by CluckShot View Post
    First Thanks!

    Next I will try your solution and report the results and report if there are any problems.

    Finally: Please tell me why this should work. In trying to read all the fun stuff down in the chip technical papers I must be missing something and I definitely want to be more astute as to why as well as how.

    Thanks again
    Paul
    Hi Paul,
    To find out more about mister_e’s helpful answer, you can use, the forum search engine, to look for:
    ADCON1=$0F

    The data sheets can be searched the same way.

    -Adam-
    Ohm it's not just a good idea... it's the LAW !

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


    Did you find this post helpful? Yes | No

    Default

    FYI, this DEFINE is the default one, if you don't write it yourself, PBP will do it for you in background.

    Let's see what happen in the .LST file, i compile those lines...
    Code:
    Define LCD_DREG PORTD ' Define LCD connections
    Define LCD_DBIT 4
    Define LCD_RSREG PORTE
    Define LCD_RSBIT 0
    Define LCD_EREG PORTE
    Define LCD_EBIT 1
    
    LCDOUT "Hello"
    Now, i open the .LST file, scroll to the end... and
    Code:
    LCD_BITS                          00000004
    LCD_COMMANDUS                     000007D0
    LCD_DATAUS                        00000032
    LCD_DBIT                          4
    LCD_DREG                          PORTD
    LCD_EBIT                          1
    LCD_EREG                          PORTE
    LCD_LINES                         00000002
    LCD_RSBIT                         0
    LCD_RSREG                         PORTE
    LCD_RWBIT                         00000000
    LCD_RWREG                         00000009
    everything is there. Now what happen, if i don't use any DEFINE
    Code:
    lcdout "Hello"
    .LST
    Code:
    LCD_BITS                          00000004
    LCD_COMMANDUS                     000007D0
    LCD_DATAUS                        00000032
    LCD_DBIT                          00000000
    LCD_DREG                          00000005 
    LCD_EBIT                          00000003
    LCD_EREG                          00000006
    LCD_LINES                         00000002
    LCD_RSBIT                         00000004
    LCD_RSREG                         00000005
    LCD_RWBIT                         00000004
    LCD_RWREG                         00000005
    Interesting eh! But i agree, it's always nice to have ALL DEFINE in your code, so if one day you decide to change them, it's just easy. PICMultiCalc also generate those.. kinda lazy stuff... and some day i am

    ---------------------------------------

    Finally: Please tell me why this should work. In trying to read all the fun stuff down in the chip technical papers I must be missing something and I definitely want to be more astute as to why as well as how.
    Well, why ADCON1 would have to work? Where did you get this value ?

    Let's see a datasheet snip...
    <IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1634&stc=1&d=117924073 8">

    ADCON1=7 set PCFG3:PCFG0 to 0111.. right? If so, what happen to AN0,1,2,3,4,5,6,7 ?

    ADCON1=$0F set PCFG3:PCFG0 to 1111.. right? If so, what happen to AN0,1,2,3,4,5,6,7,8,9,10,11,12 ?

    I think it's the explanation :-)

    EDIT: Sorry PicUser.. we write at the same time !
    Attached Images Attached Images  
    Steve

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

  7. #7
    Join Date
    May 2007
    Location
    Harvest, Alabama
    Posts
    10


    Did you find this post helpful? Yes | No

    Smile Thanks

    You confirmed my research and it is always nice to have someone back up your thinking. It either means that the both of you are lost ... (not in this case) or that you actually understand what the other person is saying. (something nice)

    In any case thanks so much and I am sure I will be back and hopefully I will have nice helpful things for others as well.

    Paul

Similar Threads

  1. using ISD2560 on PIC18F4620
    By rookie in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 15th December 2008, 05:48
  2. PIC18F4620 Programming problem
    By JavPar in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 6th December 2008, 04:21
  3. ADCIN with PIC18F4620
    By Brian J Walsh in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th July 2008, 01:25
  4. PIC18F4620 Using the Internal Oscillator
    By kiwipiper in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd October 2007, 08:07
  5. PIC18F4620 not Target Device
    By kiwipiper in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th October 2007, 19:42

Members who have read this thread : 1

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